Sockets must be closed in the runnable, otherwise they get closed too soon.