refactor the service stopping phase