Fix graceful shutdown crash.