public synchronized void shutdown() {
        securityContext.asProcessingUser(() -> {
            LOGGER.info(() -> "Index shard writer cache shutdown");
            LOGGER.logDurationIfDebugEnabled(() -> {
                try {
                    // Close any remaining writers.
                    cache.clear();

                    // Report on closing progress.
                    if (!openShards.isEmpty()) {
                        // Create a scheduled executor for us to continually log index shard writer action progress.
                        try (final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor()) {
                            // Start logging action progress.
                            executor.scheduleAtFixedRate(() ->
                                            LOGGER.info(() ->
                                                    "Waiting for " + openShards.size() + " index shards to close"),
                                    10,
                                    10,
                                    TimeUnit.SECONDS);

                            while (!openShards.isEmpty()) {
                                ThreadUtil.sleep(500);
                            }
                            // Shut down the progress logging executor.
                            executor.shutdown();
                        }
                    }
                } catch (final UncheckedInterruptedException e) {
                    LOGGER.error(e::getMessage, e);
                    // Continue to interrupt this thread.
                    Thread.currentThread().interrupt();
                }
            }, "Index shard writer cache shutdown");
        });
    }
This is called by the lifecycle service and remove writers that are past their TTL, TTI or LRU
items that exceed the capacity.
stroom-index/stroom-index-impl/src/main/java/stroom/index/impl/IndexShardWriterCacheImpl.java