zlib: introduce pending close state

zlib should not crash in `close()` if the write is still in progress.

fix #7101