zlib: do not crash on write after close

fix #7767