private synchronized void doStop() {
        try {
            // Wait for startup to complete.
            while (!startRemaining.await(1, TimeUnit.SECONDS)) {
                LOGGER.info("Waiting for startup to finish before shutting down");
            }

            stopRemaining = new CountDownLatch(stopPending.size());
            stopNext();

            try {
                // Wait for stop to complete.
                stopRemaining.await();

            } catch (final InterruptedException e) {
                LOGGER.error(e.getMessage(), e);

                // Continue to interrupt this thread.
                Thread.currentThread().interrupt();
            }

            LOGGER.info("Stopped Stroom Lifecycle service");
        } catch (final InterruptedException | UncheckedInterruptedException e) {
            LOGGER.info("Interrupted");
        }
    }
Called when the application context is destroyed.
stroom-lifecycle/stroom-lifecycle-impl/src/main/java/stroom/lifecycle/impl/LifecycleService.java