Fix temporary files not being flushed