public void register(GracefulShutdownHook shutdownHook) {
        if (isShuttingDown.get()) {
            // Avoid any changes to the shutdown hooks set when the shutdown is already in progress
            throw new IllegalStateException("Couldn't register shutdown hook because shutdown is already in progress");
        }
        shutdownHooks.add(requireNonNull(shutdownHook, "shutdownHook cannot be null"));
    }
@Test
    public void withExceptionOnShutdown() throws Exception {
        final AtomicBoolean hook1Called = new AtomicBoolean(false);
        final AtomicBoolean hook2Called = new AtomicBoolean(false);

        shutdownService.register(() -> hook1Called.set(true));
        shutdownService.register(() -> { throw new Exception("eek"); });

        stop(shutdownService);

        assertThat(hook1Called).isTrue();
        assertThat(hook2Called).isFalse();
    }