Added convenience method to register a shutdown hook.