Added server shutdown error handling.