update thread terminate logic