Catching all exceptions on shutdown