public void halt() {
        synchronized (this) {
            // Clean up any connectors and tasks that are still running.
            log.info("Stopping connectors and tasks that are still assigned to this worker.");
            worker.stopAndAwaitConnectors();
            worker.stopAndAwaitTasks();

            // Explicitly fail any outstanding requests so they actually get a response and get an
            // understandable reason for their failure.
            DistributedHerderRequest request = requests.pollFirst();
            while (request != null) {
                request.callback().onCompletion(new ConnectException("Worker is shutting down"), null);
                request = requests.pollFirst();
            }
            stopServices();
        }
    }
Perform an orderly shutdown when triggered via {@link #stop()}
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/distributed/DistributedHerder.java