Improve server shutdown and stop.