[FirmwareUpgrade] fix possible BSOD and cleanup.