Added closing sockets

Shouldn't we close sockets after they are not needed anymore, or in case of IOCTL that failed?