public void register(Runnable shutdownFunction)    {
        shutdownStack.push(shutdownFunction);
    }
@Test
    public void testOrdering() throws InterruptedException {
        ShutdownHook hook = new ShutdownHook();

        CountDownLatch latchOne = new CountDownLatch(1);
        CountDownLatch latchTwo = new CountDownLatch(1);
        CountDownLatch latchThree = new CountDownLatch(1);

        hook.register(() -> {
            try {
                latchTwo.await();
                latchThree.countDown();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

        hook.register(() -> {
            try {
                latchOne.await();
                latchTwo.countDown();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });

        hook.register(latchOne::countDown);

        CompletableFuture.runAsync(hook);

        boolean completed = latchThree.await(5_000L, TimeUnit.MILLISECONDS);
        assertThat("Last latch did not complete", completed, is(true));
    }