code: public static void shutdownExecutorService(Class clazz,
        ExecutorService executorService, Logger logger) throws InterruptedException{
      executorService.shutdown();
      if (!executorService.awaitTermination(DEFAULT_EXECUTOR_SERVICE_SHUTDOWN_TIME_IN_MINUTES, TimeUnit.MINUTES)) {
        logger.warn("Executor service shutdown timed out.");
        List<Runnable> pendingTasks = executorService.shutdownNow();
        logger.warn(String
            .format("%s was shutdown instantly. %s tasks were not executed: %s", clazz.getName(), pendingTasks.size(),
                StringUtils.join(pendingTasks, ",")));
      }
    }
docs: *
  Initiates an orderly shutdown in which previously submitted
  tasks are executed, but no new tasks are accepted.
  Invocation has no additional effect if already shut down.
  
  This also blocks until all tasks have completed execution
  request, or the timeout occurs, or the current thread is
  interrupted, whichever happens first.
  @param clazz {@link Class} that invokes shutdown on the {@link ExecutorService}.
  @param executorService {@link ExecutorService} to shutdown.
  @param logger {@link Logger} to log shutdown for invoking class.
  @throws InterruptedException if shutdown is interrupted.