fixed thread exit condition