private static void addShutdownHook() throws Throwable {
        LOG.info("Adding ShutdownHook");
        try { // adding shutdown hook
            Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook()));
            LOG.info("ShutdownHook added");
        } catch (Throwable t) {
            LOG.error("Adding the ShutdownHook failed because: ", t);
            throw t;
        }
    }