public void contextDestroyed(ContextClosedEvent event) {

    // Stop all running threads those are created in Pulse
    // Stop cluster threads
    repository.removeAllClusters();

    WebApplicationContext applicationContext =
        (WebApplicationContext) event.getApplicationContext();
    ServletContext servletContext = applicationContext.getServletContext();

    logger.info("{}{}", resourceBundle.getString("LOG_MSG_CONTEXT_DESTROYED"),
        servletContext.getContextPath());
  }
This class is used for checking the application running mode i.e. Embedded or not

@since GemFire version 7.0.Beta 2012-09-23
geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java