Merge "delete socket when the thread is destroyed"