Sockets: when and how to close them?