Check for closed connection while streaming results

Raise an exception if we find an error at the end of streaming results. This may mean that not all results have been read by the client, and it ought to know about that. Fixes #369.