Task Scheduler ending task due to timeout does not shut down ATCMD.exe

I am not sure if this is an Automise issue, or a Windows issue, but it is a problem and I am hoping that there is a solution: I have an Automise process that is scheduled to run every 3 hours starting at 1 AM. The process usually takes 45-120 minutes, but I have put a flag on the scheduled task (in Windows Task Scheduler) to shut it off if it goes for 175 minutes. The idea is that the process will get ended so that the next scheduled process will run 3 hours later.

What happens, though, is that if the 1 AM run is still going at 3:55 AM, then the task scheduler terminates the task but does NOT kill the related ATCMD.exe process. So, when the process tries to run at 4 AM, it finds that ATCMD.exe is already running and terminates immediately. Same at 7 AM, and onwards until I kill the ATCMD.exe process in Task Manager manually.

Is this the way Automise is supposed to work? What is the best way to get it to "reset" if it is stuck, so that the next run of the process will work correctly?

Not sure why it isn't terminating atcmd. I ran a test here which atcmd running an infinite while loop and it terminated. Unfortunately with windows, there is no way in a console application to gracefully exit when the process is being terminated by the scheduler or taskkill.

What is your project doing? Perhaps it can be restructured to run for shorter periods and terminate when done, or split up into multiple projects. If you send the project to support we can take a look at it and see what it does, perhaps that might help us reprodue the issue or provide some suggestions on how to restructure.

The project, under normal circumstances, does not run for even close to 3 hours. Sometimes, though, the project gets stuck on one particular step (perhaps a query from a database or an iteration on a file) and cannot free itself.

When you tested, did you test with the Windows Task Scheduler running the process and then terminating it after running for X minutes? Or did you test outside of the task scheduler completely?