code: public void close() {
      fsRunning = false;
      try {
        if (pendingReplications != null) {
          pendingReplications.stop();
        }
        if (hbthread != null) {
          hbthread.interrupt();
        }      
        if (underreplthread != null) {
          underreplthread.interrupt();
        }
        if (overreplthread != null) {
          overreplthread.interrupt();
        }
        if (raidEncodingTaskThread != null) {
          raidEncodingTaskThread.interrupt();
        }
        if (dnthread != null) {
          dnthread.interrupt();
        }
        if (automaticEditsRollingThread != null) {
          automaticEditsRoller.stop();
          // We cannot interrupt roller thread. For manual failover, we want
          // the edits file operations to finish.
          automaticEditsRollingThread.join();
        }
        if (safeMode != null) {
          safeMode.shutdown();
        }
      } catch (Exception e) {
        LOG.warn("Exception shutting down FSNamesystem", e);
      } finally {
        // using finally to ensure we also wait for lease daemon
        try {
          LOG.info("Stopping LeaseManager");
          stopLeaseMonitor();
          if (InjectionHandler
              .trueCondition(InjectionEvent.FSNAMESYSTEM_CLOSE_DIRECTORY)) {
            if (dir != null) {
              LOG.info("Stopping directory (fsimage, fsedits)");
              dir.close();
            }
          }
        } catch (InterruptedException ie) {
        } catch (IOException ie) {
          LOG.error("Error closing FSDirectory", ie);
          IOUtils.cleanup(LOG, dir);
        }
      }
    }
docs: Close down this file system manager.
  Causes heartbeat and lease daemons to stop; waits briefly for
  them to finish, but a short timeout returns control back to caller.