Fix server shutdown process.