Unfortunately, there’s no linkage between the command environment and the GUI. When you use
taskkill to kill an application, it’s acting on the process, not the window. This is an important distinction because by killing a process, you’re doing it forcefully; the same as if it has crashed. This probably isn’t what you want to be doing most of the time.
Normally, pressing Alt+F4 will close the currently focused window (or Esc if it’s a dialog box). This shortcut is equivalent to choosing File -> Quit from the menu bar or clicking the Close button on the title bar.
Basically, you’d be calling the script from the command line via your voice control program.
Note that the application will do its normal closing routine (e.g. prompting you to save your work, etc), so it’s not a forced termination the way
taskkill would do it.