closing sockets and deleting objects