check return value of gzclose to detect unfinished gzip stream
Use Z_OK instead of 0. Uncrustify.