There are some unhandled exceptions thrown when running the method RuntimeServiceFactory.UnloadServices
. This happens for example during the WorkQueueIntegrationTests run.
The problem is caused by timers running in some of the services. Handlers of these timers call the ServiceManager.Services.GetService
method which may or may not return null depending on how fast the handler runs and when it was started.
The solution would be to wait for all the timers to stop and only then unload the services.