@Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        try {
        
            // Clean up reference to Guice injector
            servletContextEvent.getServletContext().removeAttribute(GUICE_INJECTOR);

            // Shutdown TokenSessionMap, invalidating all sessions (logging all
            // users out)
            if (sessionMap != null)
                sessionMap.shutdown();

            // Unload authentication for all extensions
            if (authProviders != null) {
                for (AuthenticationProvider authProvider : authProviders)
                    authProvider.shutdown();
            }

            // Inform any listeners that application shutdown has completed
            try {
                listenerService.handleEvent(new ApplicationShutdownEvent() {
                    // The application shutdown event currently has no content
                });
            }
            catch (GuacamoleException e) {
                logger.error("An extension listening for application shutdown failed: {}", e.getMessage());
                logger.debug("Extension failed internally while handling the application shutdown event.", e);
            }

        }
        finally {

            // NOTE: This temporary file cleanup must happen AFTER firing the
            // ApplicationShutdownEvent, or an extension that relies on a .jar
            // file among those temporary files might fail internally when
            // attempting to process the event.

            // Regardless of what may succeed/fail here, always attempt to
            // clean up ALL temporary files
            if (temporaryFiles != null)
                Lists.reverse(temporaryFiles).stream().forEachOrdered(this::deleteTemporaryFile);

        }

        // Continue any Guice-specific cleanup
        super.contextDestroyed(servletContextEvent);

    }
Deletes the given temporary file/directory, if possible. If the deletion
operation fails, a warning is logged noting the failure. If the given
file is a directory, it will only be deleted if empty.

@param temp
    The temporary file to delete.
guacamole/src/main/java/org/apache/guacamole/GuacamoleServletContextListener.java