Cleanup
Added support for closing socket