code: private void registerShutdownHook() {
          if (this.shutdownHook == null) {
              // No shutdown hook registered yet.
              this.shutdownHook = new Thread() {
                  @Override
                  public void run() {
                      synchronized (startStopMonitor) {
                          LOGGER.info("JVM shutting down");
                          Container.this.doStop();
                      }
                  }
              };
              Runtime.getRuntime().addShutdownHook(this.shutdownHook);
          }
      }
docs: Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it
  has already been closed at that time.
  <p>
  Delegates to {@code doClose()} for the actual closing procedure.
  
  @see Runtime#addShutdownHook
  @see #close()
  @see #doClose()