Fixed fd leak where files were unlinked w/o being closed first.