Correctly close sockets after use.