# Global shutdown key

**URL:** <https://discourse.psychopy.org/t/global-shutdown-key/16732>\
**Category:** Coding\
**Created:** [September 24, 2020, 7:46am UTC](https://discourse.psychopy.org/t/global-shutdown-key/16732 "2020-09-24T07:46:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dara](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Dara](https://discourse.psychopy.org/u/Dara)\
**Post date:** [September 24, 2020, 7:46am UTC](https://discourse.psychopy.org/t/global-shutdown-key/16732/1 "2020-09-24T07:46:26Z")

</div>

Hey everyone!  
Just last night I was having a hard time implementing a global shutdown key for my experiment.  
The problem was that once I set the `func` argument of `event.globalKeys.add()` to `core.quit`,  
when running the code and pressing the key, a systemexit exception was thrown that I did not catch in the code, therefore preventing the program from shutting down.  
As I did not see this problem being mentioned in the documentation, I thought maybe this topic could be of help to some developers facing the same issue.  
The solution however is to call the function as below:

```auto
event.globalKeys.clear()
event.globalKeys.add(key='q', func=os._exit, func_args=[1], func_kwargs=None)

```

This will quit the program without raising any exceptions and I think this exception should be mentioned in the documentation.
