Switching to the stream's close event rather than end end event on the socket connection close because end does not always fire.