fully implemented thread exit