Move cleanup from event thread to caller. This handles cases (unit tests) where the task is never started. The pexitsem flag serves as the indicatior that the event task was started.