Atomic writes must close the file before rename.

Work around some thread safety issues in rubinius.