//The thread termination hook must also clear any variable so that it works within a thread pool