Fixed IllegalStateException caused by shutdown hook registration in another shutdown hook