[#1288] Stop gracefully when running as a Windows service.

Problem description
====

We need to stop the server gracefully when running as a Windows Service.

Changes description
=====

Refactored service stop flow.

How to try and test the changes
====

reviewers @adiroiban 

Check that code changes make sense and all the tests pass.