Moved deleting the maintenace temporary file flag to very end of upgrade task