Fix fold expansion when script exits before fold finishes