AFNI format datasets are opened and closed with popen and pclose, but NIFTI format datasets are handled with the znzlib, which uses the zlib function gzopen, gzclose and a variety of gz... functions for writing. I suspect there is some odd buffering problem on the distributed file system that might be handled with a combination of flush and sleeps before and after gzclose. That's all in one file, znzlib.c, or in nifti2_io.c, so a rebuild with the small changes and tests might reveal something. Also trying with the AFNI format instead or with Chris R's modifications might work.