Improved error handling

...and removed the implicit signalling of a close as that is the responsibility of the caller.