public void shutDownAndAwaitTermination(Duration timeout) {
    executorService.shutdown();

    try {
      if (!executorService.awaitTermination(timeout.getSeconds(), TimeUnit.SECONDS)) {
        executorService.shutdownNow();
        if (!executorService.awaitTermination(timeout.getSeconds(), TimeUnit.SECONDS)) {
          LOGGER.log(Level.SEVERE, "Could not shut down SingleThreadedExecutor");
        }
      }

    } catch (InterruptedException ex) {
      executorService.shutdownNow();
      Thread.currentThread().interrupt();
    }
  }
Shuts down the {@link #executorService} and waits for it to terminate.

@param timeout timeout to wait. The method may call {@link ExecutorService#awaitTermination}
    times with the given timeout, so the overall wait time can go up to 2 times the timeout
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/logging/SingleThreadedExecutor.java