close thread socket when done