some small changes to the server shutdown process to prevent it from hanging