code: protected void stopServing() throws Exception {
      if (isServing()) {
        if (!mGrpcServer.shutdown()) {
          LOG.warn("RPC Server shutdown timed out.");
        }
      }
      if (mRPCExecutor != null) {
        mRPCExecutor.shutdown();
        try {
          mRPCExecutor.awaitTermination(
              ServerConfiguration.getMs(PropertyKey.MASTER_GRPC_SERVER_SHUTDOWN_TIMEOUT),
              TimeUnit.MILLISECONDS);
        } catch (InterruptedException ie) {
          Thread.currentThread().interrupt();
        } finally {
          mRPCExecutor.shutdownNow();
        }
      }
      if (mJvmPauseMonitor != null) {
        mJvmPauseMonitor.stop();
      }
      if (mWebServer != null) {
        mWebServer.stop();
        mWebServer = null;
      }
      MetricsSystem.stopSinks();
    }
docs: Stops serving, trying stop RPC server and web ui server and letting {@link MetricsSystem} stop
  all the sinks.