You can use wix built-in function called CloseApplication, it was designed to doaddress that exactly thingscenario: https://docs.firegiant.com/wix/schema/util/closeapplication/
<util:CloseApplication
Id="CloseApp"
PromptToContinue="yes"
Description="The setup wants to close Word."
CloseMessage="yes"
Target="Word.exe"
RebootPrompt="no"
/>
BTW, I really don't think you need to close Word (like I've stated in the comment), if you get an error during installation it may be something else.