Fix spawn of compress_cmd hang

Spawn of compress_cmd hangs if pipe_wr is not closed before spawning.
Should fix: gitlabhq/gitlabhq#6922

This bug hits the download as archive function.
It makes the website hang when trying to download an archive and can create empty tar.gz files.