tweaked the thread close function