Fixed a bug where the service wouldn't always shut down correctly

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>