Illegal argument exception when adding shutdown hook