Improve code style for exception_caused_by_shutdown?