You can try the following in your shutdown script:
import fme
import os
if not fme.status:
    os.remove(fme.macroValues('source_file'])
This will delete the file referenced in the parameter "source_file" if the workspace failed, e.g. with a Terminator.
Thanks @david_r, indeed that worked. Oddly I still got an error with your code. In the end, the issue had to do with the "type" of the published parameter that holds the filename (that parameter was created by someone else). So I re-created the parameter as a text type, and that made both the FeatureReader and the exit script Python happy.Â
Below I'm including the error I got prior to re-creating the parameter, in case the same thing happens to anyone else. That issue with the parameter type took far too much time to track down, believing the problem had to do with a mistake in my use of the Python in the shutdown script.
FME_END_PYTHON: evaluating python script from string...
END - ProcessID: 16548, peak process memory usage: 185908 kB, current process memory usage: 82432 kB
Python Exception <WindowsError>: ÂError 123] The filename, directory name, or volume label syntax is incorrect: 'c:<backslash>folder<backslash>roger<backslash>file.ext'
Error executing string `import fme
import os
if not fme.status:
    os.remove(fme.macroValues&'source_file'])
'
FME_END_PYTHON failed to execute provided script
Terminator_5: Termination Message: 'Translation Terminated due to too many features in file'
Program Terminating
Translation FAILED.
Thanks again.