# Script closing popup, when user clicks somewhere else on the screen

**URL:** <https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [August 9, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838 "2022-08-09T17:51:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 9, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838/1 "2022-08-09T17:51:23Z")

</div>

Ignition 7.8.5 vision

I noticed the other day an excessive amount of windows open. I then realized if you dont click the close button or red x the popup does not close even though it is not visible.

I was wondering of a way to script closing said popup, when user does not properly close. I didn’t see any good event handlers on the root container for handling this.

Any ideas would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 9, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838/2 "2022-08-09T17:57:50Z")

</div>

NVM lol . mouseexited looks to be what I need.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 10, 2022, 2:43am UTC](https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838/3 "2022-08-10T02:43:37Z")

</div>

You might also want to set the popup Window’s `Layer` to something greater than the layer of your main displays as well so that popups can’t physically be behind your main Windows.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0bf962791e6e194496530eba5647b604794531d6.png)

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 10, 2022, 2:13pm UTC](https://forum.inductiveautomation.com/t/script-closing-popup-when-user-clicks-somewhere-else-on-the-screen/62838/4 "2022-08-10T14:13:39Z")

</div>

@nminchin that’s a good “best practice” going forward. But If I don’t add the exit script I know i’m gonna get calls about windows not closing. lol.
