synchronized void waitForQuiescence() throws InterruptedException {
            while ((!shutdown) || (refCount > 0)) {
                this.wait();
            }
        }
The shutdown manager handles shutting down gracefully.

We can shut down gracefully only when all the references handed out
by the ShutdownManager has been closed, and the shutdown bit has
been set.  RPC operations hold a reference for the duration of their
execution, and so do Workers which have not been shut down.
This prevents us from shutting down in the middle of an RPC, or with
workers which are still running.
trogdor/src/main/java/org/apache/kafka/trogdor/agent/WorkerManager.java