Ok, I have removed all code that shuts down tasks and waits for them to stop.