code: private void addShutdownHook(boolean isClient) {
          if (shutdownHook == null) {
              shutdownHook = new ShutdownHook(isClient);
              Runtime.getRuntime().addShutdownHook(shutdownHook);
          }
      }
docs: Attach a shutdown hook to make sure that the framework is shutdown nicely
  in most cases. There are ways of shutting a JVM down that don't use the
  shutdown hook, but this catches most cases.