code: private void shutdownImpl(ShutdownModeAmp mode, 
                              ExitCode exitCode,
                              Result<String> result)
    {
      // start the fail-safe thread in case the shutdown fails
      FailSafeHaltThread haltThread = _failSafeHaltThread;
      
      if (haltThread != null) {
        haltThread.startShutdown();
      }
  
      if (exitCode == null) {
        exitCode = ExitCode.FAIL_SAFE_HALT;
      }
      
      _exitCode.compareAndSet(null, exitCode);
  
      try {
        SystemManager systemManager = _systemManagerRef.get();
          
        if (systemManager != null) {
          systemManager.shutdown(mode);
        }
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);
      } finally {
        _systemManagerRef = null;
        _lifecycle.toDestroy();
  
        System.err.println("\nShutdown reason: " + exitCode + "\n");
  
        log.warning("Shutdown reason: " + exitCode);
        
        if (result != null) {
          result.ok("Shutdown reason: " + exitCode);
        }
  
        if (! _isEmbedded) {
          System.exit(exitCode.ordinal());
        }
      }
    }
docs: Closes the server.