code: public void stop() {
      if (stopRequested)
        return;
      stopRequested = true;
      LOG.info("Stopping http server");
      try {
        if (httpServer != null) httpServer.stop();
      } catch (Exception e) {
        LOG.error(StringUtils.stringifyException(e));
      }
  
      LOG.info("Stopping namesystem");
      if(namesystem != null) namesystem.close();
  
      LOG.info("Stopping emptier");
      if(emptier != null) emptier.interrupt();
  
      LOG.info("Stopping rpc servers");
      if(server != null) server.stop();
      if (dnProtocolServer != null) dnProtocolServer.stop();
  
      LOG.info("Stopping metrics");
      if (myMetrics != null) {
        myMetrics.shutdown();
      }
  
      LOG.info("Stopping namesystem mbeans");
      if (namesystem != null) {
        namesystem.shutdown();
      }
    }
docs: Stop all NameNode threads and wait for all to finish.