# Quit and wait until quit

**URL:** <https://forum.juce.com/t/quit-and-wait-until-quit/24775>\
**Category:** General JUCE discussion\
**Created:** [October 24, 2017, 9:32am UTC](https://forum.juce.com/t/quit-and-wait-until-quit/24775 "2017-10-24T09:32:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 24, 2017, 9:32am UTC](https://forum.juce.com/t/quit-and-wait-until-quit/24775/1 "2017-10-24T09:32:49Z")

</div>

I’m integrating WinSparkle into a JUCE app. The app has to close down a number of threads and internet connections potentially when it exits. And I need that to happen before the installer kicks off really.

So given that I have a call to JUCEApplication::quit() that happens on a non-message thread is there any easy way of blocking that thread until the app is pretty much ready to exit and the other threads are stopped. I can think of some hard ways…

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 24, 2017, 9:36am UTC](https://forum.juce.com/t/quit-and-wait-until-quit/24775/2 "2017-10-24T09:36:31Z")

</div>

s’ok … I think I have a solution

---

<div class="post-metadata">

**Author:** ![jimc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jimc/32/16067_2.png) [@jimc](https://forum.juce.com/u/jimc)\
**Post date:** [October 24, 2017, 9:38am UTC](https://forum.juce.com/t/quit-and-wait-until-quit/24775/3 "2017-10-24T09:38:05Z")

</div>

Yep - solution is:

- Move the updater classes to Main.cpp from MainComponent.
- Put a flag that’s set when MainComponent and everything else non-essential is deleted.
- Block until the flag is set
- Return from my ‘request quit’ callback to the auto-updater code
