If you schedule the upgrade MSI during the transaction, for example use:
MajorUpgrade/@Schedule='afterInstallInitialize'
orMajorUpgrade/@Schedule='afterInstallExecute'
orMajorUpgrade/@Schedule='afterInstallExecuteAgain'
and use the ServiceControl
element to start/stop/restart the service then the Windows Installer will do all the work for you.
This is by far the most recommended way to accomplish your goal.