Add function for adding shutdown hooks.