Close a socket after end at the reader thread