Fixed termination of a async socket connection.