OnExit = "cancel" can fail if the standard WIX UI is used (WIX assigns a different action for the "cancel" event). In this case, the execution of the action can be assigned to the completion button.
<Publish Dialog="UserExit" Control="Finish" Event="DoAction" Value="MyAction">NOT Installed</Publish>
source share