Return stream id to the pool in case of a write error.

Return stream id to the pool in case of a write error.