# Proper Way To Close a multi-window app on Windows

**URL:** <https://forum.juce.com/t/proper-way-to-close-a-multi-window-app-on-windows/14867>\
**Category:** Windows\
**Created:** [May 28, 2015, 7:28pm UTC](https://forum.juce.com/t/proper-way-to-close-a-multi-window-app-on-windows/14867 "2015-05-28T19:28:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bradley\_Rothenberg](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@Bradley\_Rothenberg](https://forum.juce.com/u/Bradley_Rothenberg)\
**Post date:** [May 28, 2015, 7:28pm UTC](https://forum.juce.com/t/proper-way-to-close-a-multi-window-app-on-windows/14867/1 "2015-05-28T19:28:41Z")

</div>

Hello All,

&nbsp;

I am still pretty new to Juce, but I am just starting to nuild a multi-window app, & when using the closeButtonPressed function in both windows to exit out of the app:

```
    void closeButtonPressed() override
    {
        JUCEApplication::getInstance()->systemRequestedQuit();
    }
```

I am getting a breakpoint thrown from the LeakedObjectDetector, which I think is because it is trying to delete a pointer to a window which was already deleted?&nbsp;When I have one window, the close works fine, or if one window has the closeButtonPress function, & the other doesn't the close works fine too.&nbsp;

&nbsp;

I was wondering if anyone has a good method for closing multi-window apps, of if there is a bettor method?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 28, 2015, 7:57pm UTC](https://forum.juce.com/t/proper-way-to-close-a-multi-window-app-on-windows/14867/2 "2015-05-28T19:57:05Z")

</div>

Maybe have a look at how the Introjucer handles this?

---

<div class="post-metadata">

**Author:** ![Bradley\_Rothenberg](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@Bradley\_Rothenberg](https://forum.juce.com/u/Bradley_Rothenberg)\
**Post date:** [May 28, 2015, 9:59pm UTC](https://forum.juce.com/t/proper-way-to-close-a-multi-window-app-on-windows/14867/3 "2015-05-28T21:59:04Z")

</div>

Thanks Julian,&nbsp;

&nbsp;

but the error we are running into is because we have two windows with two openGL contexts running -- The object that is trying to be deleted is juce::OpenGLRendering::ShaderPrograms. Also, the crash only seems to be happening on windows, & not on osx.

&nbsp;

&nbsp;
