Fix closing file when on remote