Fix leak of File instances when script is unloaded before GC