The fix itself seems really easy, but I am not sure how to test this in an automated manner. I did some manual test, but I don't know (yet) how to extend ShutdownHookTest to fit this in.