Forum Discussion
Great thread — lots of solid tips already!
Just to sum it up for anyone checking this out later: you can stop a test run with Runner.Stop() or Runner.Halt(), optionally close TestComplete (or TestExecute) using Sys.Process("TestComplete").Terminate() — or call a PowerShell script if you want a cleaner shutdown.
Here’s a quick example in JavaScript:
function checkConditionAndExit() {
if (Project.Variables.MyFlag == true) {
Log.Message("Condition met — stopping and closing TestComplete...");
Runner.Stop(true); // stop execution
}
}
I’d still be careful with Terminate() — it’s basically the “pull the plug” option and can skip saving logs or logging out from license. If you’re running from the command line, the /exit flag is still the smoothest way to finish up.
🤖 AI-assisted response
👍 Found it helpful? Click Like
✅ Issue resolved? Click Mark as Solution
- rraghvani2 months ago
Champion Level 3
I have no idea why your ChatGPT has suggested to terminate the process of TestComplete, and then suggesting to be careful!? If you are running automation, don't terminate the TC process! Also, the remaining lines after Runner.Stop(true) will not get called!
- Hassan_Ballan2 months ago
Champion Level 3
You’re right — suggesting Sys.Process("TestComplete").Terminate() was a mistake. That’s unsafe and any code after Runner.Stop(true) won’t run.
The correct way is just to use Runner.Stop() or Runner.Halt(), and use the /exit flag from the command line if you want TestComplete/TestExecute to close automatically.
Thanks for pointing this out!