zlib: do not crash on write after close