Hi @rhartley
The following Python Code, when used as a Shutdown Python Script, will close down FME Workbench for you. The Python code essentially invokes Taskkill on the Parent ProcessID of the application running the Workspace. Now, there are two methods to close an application using Taskkill; a nice way and the forceful way.
Using the Force switch (/F) with Taskkill does come with a caveat when it's used in FME Workbench though:
If you have AutoSave switched on, doing a Force close will leave a recovery file behind. The next time the Workspace is opened the user will be warned about the recovery file. The user is not necessarily going to be expecting that, or even know what it is.
If, on the other hand, you choose not to use the Force switch in the Python code, then the user will get prompted to Save the Workspace, before it is closed, if any changes have been made to it since it was opened. This is okay, unless the user clicks Cancel and then FME Workbench stays open, defeating the point somewhat.
Here is the Python Code to be pasted into the Workspace Parameters | Scripting | Shutdown Python Script dialog:
import subprocess
import os
parentPid = os.getppid()
taskKill = subprocess.Popen(['Taskkill.exe', '/PID', str(parentPid), '/F'],
stdin=None, stdout=None, stderr=None, close_fds=True)
Now, if we go down the route of the answer suggested by @redgeographics then we get a much cleaner solution using FME Quick Translator to run the Workspace. If we open a Workspace that contains the above Python code in the Shutdown Python Script and run it using FME Quick Translator, then both of the above problems go away! Clean exit from the application and license returned!
Hope this helps.
Thanks,
Simon