code: public void shutdown(ShutdownModeAmp mode)
    {
      stop(mode);
  
      if (! _lifecycle.toDestroy()) {
        return;
      }
      
      Thread thread = Thread.currentThread();
      ClassLoader oldLoader = thread.getContextClassLoader();
  
      try {
        thread.setContextClassLoader(_classLoader);
  
        TreeSet<SubSystem> systems
          = new TreeSet<SubSystem>(new StopComparator());
  
        systems.addAll(_systemMap.values());
  
        _systemMap.clear();
  
        for (SubSystem system : systems) {
          try {
            system.destroy();
          } catch (Throwable e) {
            log.log(Level.WARNING, e.toString(), e);
          }
        }
  
        WeakReference<SystemManager> globalRef = _globalSystemRef;
  
        if (globalRef != null && globalRef.get() == this) {
          _globalSystemRef = null;
        }
  
        /*
         * destroy
         */
  
        log.fine(this + " destroyed");
  
        _classLoader.destroy();
      } finally {
        // DynamicClassLoader.setOldLoader(thread, oldLoader);
        
        thread.setContextClassLoader(oldLoader);
  
        _classLoader = null;
      }
    }
docs: Shuts down the server in the given mode.