# Breaking out of a script

**URL:** <https://forum.inductiveautomation.com/t/breaking-out-of-a-script/30160>\
**Category:** Ignition\
**Created:** [November 21, 2019, 8:50pm UTC](https://forum.inductiveautomation.com/t/breaking-out-of-a-script/30160 "2019-11-21T20:50:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard.d.white](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@richard.d.white](https://forum.inductiveautomation.com/u/richard.d.white)\
**Post date:** [November 21, 2019, 8:50pm UTC](https://forum.inductiveautomation.com/t/breaking-out-of-a-script/30160/1 "2019-11-21T20:50:41Z")

</div>

Hello! Very quick (and hopefully simple) question about scripts within Ignition.

Is there any way to exit a script without completely executing it? Something like the break command, but for the entire script? The idea would be to stop the script entirely if certain conditions would otherwise cause it to throw errors. Thank you!

---

<div class="post-metadata">

**Author:** ![richard.d.white](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@richard.d.white](https://forum.inductiveautomation.com/u/richard.d.white)\
**Post date:** [November 21, 2019, 8:52pm UTC](https://forum.inductiveautomation.com/t/breaking-out-of-a-script/30160/2 "2019-11-21T20:52:36Z")

</div>

OK - I should have spent more time looking in the forum… The answer is clearly to use “return” to exit from the script!

Thanks!

---

<div class="post-metadata">

**Author:** ![richard.d.white](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@richard.d.white](https://forum.inductiveautomation.com/u/richard.d.white)\
**Post date:** [November 21, 2019, 9:05pm UTC](https://forum.inductiveautomation.com/t/breaking-out-of-a-script/30160/3 "2019-11-21T21:05:37Z")

</div>

OK I should have actually tested this before responding to my own post. To avoid further confusing people I’ll post kind of the same thing someone else commented on already (this does work):

Method one:  
from sys import exit  
exit()

Method two:  
Place entire script into function  
use return
