Close the channel when an unexpected exception occurs.
Don't use mark/reset when passing to an encoder/decoder.

Don’t assume an encoder or decoder isn’t using mark/reset itself
because if it does we would reset to an unexpected index.