code: public synchronized void shutdownTaskScheduler(){
          if (scheduler != null && !scheduler.isShutdown()) {
              scheduler.shutdown();
              logger.info("shutdowned the task scheduler. No longer accepting new tasks");
              scheduler = null;
          }
      }
docs: Shutdown task scheduler.