Fix event subscription memory leak

Fix memory leak by unsubscribing from process 'exit' event on service restart. Do some refactoring.