Clean up tasks in shutdown hook.

When the shutdown hook is called, perform a clean shutdown of services
to allow cluster listeners to be called appropriately instead of simply
removing the ephemeral node in ZK.