cleanup thread spawning