Make sure we shutdown HazelCast when the context is destroyed.
555574
public void shutdown() {
        try {
            LOGGER.info("Shutting down Hazelcast instance [{}]", this.hazelcastInstance.getConfig().getInstanceName());
            this.hazelcastInstance.shutdown();
        } catch (final Exception e) {
            LOGGER.debug(e.getMessage());
        }
    }
544290
public void deactivate(ComponentContext context) {
        if (contextRef.get() == null) {
            // Components are only deactivated if they activate successfully,
            // and component instances are discarded after being deactivated.
            // This is either DS or programmer error.
            throw new IllegalStateException("not activated");
        }

        this.contextRef.set(null);
    }
1334057
public static void closeContext(DirContext context) {
		if (context != null) {
			try {
				context.close();
			}
			catch (NamingException ex) {
				LOGGER.debug("Could not close JNDI DirContext", ex);
			}
			catch (Throwable ex) {
				// We don't trust the JNDI provider: It might throw
				// RuntimeException or Error.
				LOGGER.debug("Unexpected exception on closing JNDI DirContext", ex);
			}
		}
	}
452716
public void destroy() {
        WaylandClientCore.INSTANCE()
                         .wl_proxy_destroy(this.pointer);
        ObjectCache.remove(this.pointer);
        this.jObjectPointer.close();
    }
1077851
@Override
    public synchronized void stop(final StopContext context) {
        final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS;
        if (shutdownServers) {
            Runnable task = new Runnable() {
                @Override
                public void run() {
                    try {
                        serverInventory.shutdown(true, -1, true); // TODO graceful shutdown
                        serverInventory = null;
                        // client.getValue().setServerInventory(null);
                    } finally {
                        serverCallback.getValue().setCallbackHandler(null);
                        context.complete();
                    }
                }
            };
            try {
                executorService.getValue().execute(task);
            } catch (RejectedExecutionException e) {
                task.run();
            } finally {
                context.asynchronous();
            }
        } else {
            // We have to set the shutdown flag in any case
            serverInventory.shutdown(false, -1, true);
            serverInventory = null;
        }
    }
570137
public void shutdown(ShutdownModeAmp mode)
  {
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();

    try {
      thread.setContextClassLoader(classLoader());

      if (! _lifecycle.toStopping()) {
        return;
      }
      
      //_httpCache.close();

      try {
        shutdownImpl(mode);
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);
      }

      _lifecycle.toDestroy();
    } finally {
      thread.setContextClassLoader(oldLoader);
    }
  }
88321
@Override
    public void shutdown() {
        Throwable shutdownException = null;
        try {
            fire(new ManagerStopping());
        } catch (Exception e) {
            try {
                fireException(e);
            } catch (Exception e2) {
                shutdownException = e2;
            }
        }
        synchronized (this) {
            for (Context context : contexts) {
                context.clearAll();
            }
            contexts.clear();
            extensions.clear();

            runtimeLogger.clear();

            handledThrowables.remove();
        }
        if (shutdownException != null) {
            UncheckedThrow.throwUnchecked(shutdownException);
        }
    }
356187
protected void deactivate(ComponentContext context) {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "deactivate", name);

        lock.writeLock().lock();
        try {
            if (pmMBean != null) {
                pmMBean.unregister();
                pmMBean = null;
            }
            pm = null;
            properties = null;
        } finally {
            lock.writeLock().unlock();
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "deactivate");
    }
646058
public void shutdown()
    {
        Environment env = ((BaseApplication)m_app).getEnvironment();
        if (m_app != null)
        	m_app.free();
        m_app = null;
        if (ClassServiceUtility.getClassService().getClassFinder(null) != null)
            ClassServiceUtility.getClassService().getClassFinder(null).shutdownService(null, this);
        if (env != null)
        	env.freeIfDone();
//x        System.exit(0);
    }
139271
@SuppressWarnings("unchecked")
	public void deassociate(HttpServletRequest context) {
		Map<Descriptor<?>, Object> components 
				= (Map<Descriptor<?>, Object>) context.getAttribute(COMPONENTS);
		
		for (Object component : components.values()) {
			try {
				Event.of(Passivated.class).on(component).fire();
			} catch (Exception e) {}
		}
		
		context.removeAttribute(COMPONENTS);
		
		for (Object component : components.values()) {
			try {
				Event.of(Destroyed.class).on(component).fire();
			} catch (Exception e) {}
		}
	}
1034032
public function shutdownObject()
    {
        $this->cache->set('parsedFormats', $this->parsedFormats);
        $this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
        $this->cache->set('localizedSymbols', $this->localizedSymbols);
    }
988929
public static void shutdown(String instanceName) {
        HazelcastClientProxy proxy = CLIENTS.remove(instanceName);
        if (proxy == null) {
            return;
        }
        HazelcastClientInstanceImpl client = proxy.client;
        if (client == null) {
            return;
        }
        proxy.client = null;
        try {
            client.shutdown();
        } catch (Throwable ignored) {
            EmptyStatement.ignore(ignored);
        } finally {
            OutOfMemoryErrorDispatcher.deregisterClient(client);
        }
    }
892738
def stopContext(self, context):
        

        # Use pymongo directly to drop all collections of created db
        if ((self.clear_context['module'] and inspect.ismodule(context)) or
           (self.clear_context['class'] and inspect.isclass(context))):
            self.connection.drop_database(self.database_name)
400153
public void close() {
		forwardEngine.close();
		if (forwardEngine != reverseEngine) {
			reverseEngine.close();
		}
		for (Long ssrc : contexts.keySet()) {
			SRTPCryptoContext context = contexts.get(ssrc);
			if (context != null) {
				context.close();
				contexts.remove(ssrc);
			}
		}
	}
391678
private void destroy() {
        Lock writerLock = ctxLock.writeLock();
        writerLock.lock();
        try {
            if (ctx != 0) {
                if (enableOcsp) {
                    SSLContext.disableOcsp(ctx);
                }

                SSLContext.free(ctx);
                ctx = 0;

                OpenSslSessionContext context = sessionContext();
                if (context != null) {
                    context.destroy();
                }
            }
        } finally {
            writerLock.unlock();
        }
    }
375344
def teardown_socket(s):
  """"""
  try:
    s.shutdown(socket.SHUT_WR)
  except socket.error:
    pass
  finally:
    s.close()
320845
public void shutdown() {
        // call destroy on each filter instance wrapper
        Enumeration filterWrappers = _filterWrappers.elements();

        ClassLoader origClassLoader = ThreadContextHelper.getContextClassLoader();
        try {
            final ClassLoader warClassLoader = webApp.getClassLoader();
            if (warClassLoader != origClassLoader) {
                ThreadContextHelper.setClassLoader(warClassLoader);
            }
            while (filterWrappers.hasMoreElements()) {
                try {
                    FilterInstanceWrapper fw = (FilterInstanceWrapper) filterWrappers.nextElement();

                    Throwable t = this.webApp.invokeAnnotTypeOnObjectAndHierarchy(fw.getFilterInstance(), ANNOT_TYPE.PRE_DESTROY);
                    if (t != null) {
                        // log exception - could be from user's code - and move on 
                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) { // 306998.15
                            logger.logp(Level.FINE, CLASS_NAME, "shutdown", "Exception caught during preDestroy processing: " + t);
                        }
                    }

                    fw.destroy();


                } catch (Throwable th) {
                    // should probably log this...continue on to destroy all
                    // filters
                    com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(th, "com.ibm.ws.webcontainer.filter.WebAppFilterManager.shutdown",
                                                                                 "237", this);
                }
            }
        } finally {
            ThreadContextHelper.setClassLoader(origClassLoader);
        }

        // release the hash tables
        /* Nulls can cause NPE in doFilter, GC should clean these up when
         * WebAppFilterMater is no longer referenced.
        _filterWrappers = null;
        chainCache = null;
        forwardChainCache = null;
        includeChainCache = null;
        errorChainCache = null;*/
    }