core: close .upgrade files before deleting them after /upgrade