thread exit fix (uncompleted)