code: public void processEvent(SystemEvent event)
      {
          Map<String, Object> scope = null;
          
          if (event instanceof PreDestroyViewMapEvent)
          {
              UIViewRoot viewRoot = (UIViewRoot) ((PreDestroyViewMapEvent) event).getComponent();
              scope = viewRoot.getViewMap(false);
              if (scope == null)
              {
                  // view map does not exist --> nothing to destroy
                  return;
              }
          }
          else if (event instanceof PreDestroyCustomScopeEvent)
          {
              ScopeContext scopeContext = ((PreDestroyCustomScopeEvent) event).getContext();
              scope = scopeContext.getScope();
          }
          else
          {
              // wrong event
              return;
          }
          
          if (!scope.isEmpty())
          {
              Set<String> keySet = scope.keySet();
              String[] keys = keySet.toArray(new String[keySet.size()]);
              
              for (String key : keys)
              {
                  Object value = scope.get(key);
                  this.destroy(key, value);
              }
          }
      }
docs: Listens to PreDestroyCustomScopeEvent and PreDestroyViewMapEvent
  and invokes destroy() for every managed bean in the associated scope.