code: @SuppressWarnings("unchecked")
      public void processEvent(final SystemEvent event) {
          if (event instanceof PreDestroyViewMapEvent) {
              Map<Contextual<?>, Object> componentInstanceMap = getComponentInstanceMap();
              Map<Contextual<?>, CreationalContext<?>> creationalContextMap = getCreationalInstanceMap();
  
              if (componentInstanceMap != null) {
                  for (Entry<Contextual<?>, Object> componentEntry : componentInstanceMap.entrySet()) {
                      /*
                       * No way to inform the compiler of type <T> information, so it has to be abandoned here :(
                       */
                      Contextual contextual = componentEntry.getKey();
                      Object instance = componentEntry.getValue();
                      CreationalContext creational = creationalContextMap.get(contextual);
  
                      contextual.destroy(instance, creational);
                  }
              }
          }
      }
docs: We get PreDestroyViewMapEvent events from the JSF servlet and destroy our contextual instances. This should
  (theoretically!) also get fired if the webapp closes, so there should be no need to manually track all view scopes and
  destroy them at a shutdown.
  
  @see javax.faces.event.SystemEventListener#processEvent(javax.faces.event.SystemEvent)