code: @Override
    public void close() {
  
      if (closed.compareAndSet(false, true) && numThreads > 0) {
  
        LOG.log(Level.FINEST, "Closing ThreadPoolStage {0}: begin", this.name);
  
        executor.shutdown();
  
        boolean isTerminated = false;
        try {
          isTerminated = executor.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
        } catch (final InterruptedException ex) {
          LOG.log(Level.WARNING, "Interrupted closing ThreadPoolStage " + this.name, ex);
        }
  
        if (!isTerminated) {
          final List<Runnable> droppedRunnables = executor.shutdownNow();
          LOG.log(Level.SEVERE,
              "Closing ThreadPoolStage {0}: Executor did not terminate in {1} ms. Dropping {2} tasks",
              new Object[] {this.name, SHUTDOWN_TIMEOUT, droppedRunnables.size()});
        }
  
        if (!executor.isTerminated()) {
          LOG.log(Level.SEVERE, "Closing ThreadPoolStage {0}: Executor failed to terminate.", this.name);
        }
  
        LOG.log(Level.FINEST, "Closing ThreadPoolStage {0}: end", this.name);
      }
    }
docs: Closes resources.