Refactoring server stop