Handle shutdown signals