Add graceful shutdown functionality to switch.