code: private void stopThreadPool(ExecutorService threadPool) {
          LibraryUtils.checkCondition(threadPool == null, "Thread pool is null when calling stop");
  
          if (threadPool.isShutdown()) {
              logger.debug(threadPool.toString() + " is already stopped.");
  
          } else {
  
              logger.debug(threadPool.toString() + " is about to shutdown.");
              threadPool.shutdown(); // Shutdown thread pool
  
              try { // Wait for shutdown
                  threadPool.awaitTermination(config.getThreadTerminationDelaySeconds(), TimeUnit.SECONDS);
              } catch (InterruptedException e) {
                  logger.debug("Wait thread pool termination is interrupted.");
              }
  
              if (!threadPool.isShutdown()) { // ShutdownNow after waiting
                  logger.debug(threadPool.toString() + " is force to shutdown now.");
                  threadPool.shutdownNow();
              }
  
              logger.debug(threadPool.toString() + " is stopped.");
          }
      }
docs: Helper function to gracefully stop an {@link ExecutorService}.
  
  @param threadPool the thread pool to stop.