Thread fix

Thread wasn't closing on exit.