Move the thread destruction to DeInit method to hopefully prevent crash on exit.