code: private void stopServer() {
          // Get current server
          final Server targetServer = this.getServer();
  
          // Start a new thread in order to escape the destruction of this Handler
          // during the stop process.
          new Thread() {
              @Override
              public void run() {
                  try {
                      targetServer.stop();
                  } catch (Exception e) {
                      // ignore
                  }
              }
          }.start();
  
      }
docs: Start a new thread to shutdown the server