Added shutdown hook for shutdown routine.