bpo-36434: Properly handle writing errors in ZIP files. (GH-12559) (GH-12628)

Errors during writing no longer prevent to properly close
the ZIP file.
(cherry picked from commit 2524fdefc9bb2a97b99319190aeb23703079ad4c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
3 files changed