# How can we stop the execution of test script which are triggered using python scripts

**URL:** <https://forum.robotframework.org/t/how-can-we-stop-the-execution-of-test-script-which-are-triggered-using-python-scripts/4947>\
**Category:** Robot Framework\
**Created:** [16 November 2022 07:29 UTC](https://forum.robotframework.org/t/how-can-we-stop-the-execution-of-test-script-which-are-triggered-using-python-scripts/4947 "2022-11-16T07:29:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shekhar](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@shekhar](https://forum.robotframework.org/u/shekhar)\
**Post date:** [16 November 2022 07:29 UTC](https://forum.robotframework.org/t/how-can-we-stop-the-execution-of-test-script-which-are-triggered-using-python-scripts/4947/1 "2022-11-16T07:29:48Z")

</div>

I need to force stop the test case execution through python scripts when it is in running state.  
I understand “ctrl+C” does the same thing but I need to do it through python script.  
Also, I understand fatal error stop execution.  
Is there any library or API I need to call to stop execution?

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [16 November 2022 12:31 UTC](https://forum.robotframework.org/t/how-can-we-stop-the-execution-of-test-script-which-are-triggered-using-python-scripts/4947/2 "2022-11-16T12:31:26Z")

</div>

Hi Shekhar,

1. If you use [subprocess.Popen](https://docs.python.org/3.8/library/subprocess.html#subprocess.Popen) to launch the robot you can simple use [`Popen.` `terminate` ()](https://docs.python.org/3.8/library/subprocess.html#subprocess.Popen.terminate) to send the equivalent of a “ctrl+C”

2. Alternatively if you can get the PID of the robot process upi could probably use [os.kill()](https://docs.python.org/3/library/os.html#os.kill) to sent the ` signal.CTRL_C_EVENT` signal

You should be able to get one of them working, [rfswarm’s](https://github.com/damies13/rfswarm/blob/master/README.md) agent uses the 1st method.

Hope that helps,

Dave.
