private static void StopService(IServiceHost serviceHost, string errorMessage) { if (!serviceHost.IsServiceRunning) { return; } try { serviceHost.StopService(); } catch (Exception exception) { HandleException(errorMessage, exception); } }