Fixed bug causing exception when socket disconnects from server.
Fixed segfault on client close.