try {
Thread.sleep(delayMs);
LOGGER.warn("Delayed shutdown forced the application to exit with code {}.", exitCode);
- System.exit(exitCode);
+ // Method halt is used instead of System.exit, because running
+ // of shutdown hooks hangs the application in some cases.
+ Runtime.getRuntime().halt(exitCode);
} catch (InterruptedException e) {
e.printStackTrace();
}