# MacOS fix for closeWindow() in fullscreen

**URL:** <https://discourse.libcinder.org/t/macos-fix-for-closewindow-in-fullscreen/1697>\
**Category:** Using Cinder\
**Created:** [September 2, 2020, 5:58pm UTC](https://discourse.libcinder.org/t/macos-fix-for-closewindow-in-fullscreen/1697 "2020-09-02T17:58:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lemonjim](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@lemonjim](https://discourse.libcinder.org/u/lemonjim)\
**Post date:** [September 2, 2020, 5:58pm UTC](https://discourse.libcinder.org/t/macos-fix-for-closewindow-in-fullscreen/1697/1 "2020-09-02T17:58:25Z")

</div>

Hi there,

Firstly, I really enjoy Cinder! I have been using it for many years, and decided to update all my 7 apps to 64-bit under v0.9.2. It took awhile to get everything updated, and I thought one discovery might help others, and/or perhaps it will be fixed in the next release.

Take almost any samples project, build and run. Here I use _SurfaceBasic_.

Click the green dot to go into fullscreen mode. Now click the red dot to close the window (and quit the app). Xcode goes into lldb debugger and provides a traceback showing EXC\_BAD\_ACCESS in the ExecuteLaunch() function.

Here is the screen with the traceback:

 ![Screen Shot 2020-09-02 at 10.41.05 AM](https://canada1.discourse-cdn.com/flex030/uploads/libcinder/original/1X/ad429f906bd555630d85c47d37021ba35f6b798f.jpeg)

For some reason, clicking the red dot when _not_ in fullscreen mode, does not crash.

To fix this, add this line to the setup() function to catch the close signal:

getWindow()-\>getSignalClose().connect( std::bind( &yourApp::windowClosed, **this** ) );

Then make a function to handle windowClosed signals, calling a cleanup() function (if you need to free any other resources, usually none):

**void** windowClosed(); // handle window-close event  
**void** cleanup() **override** ; // override the cleanup

// ------------  
**void** yourApp::windowClosed()  
{  
console() \<\< “#OK window closed, exiting” \<\< std::endl;  
cleanup();  
}

// ------------  
**void** jjlgImageHFApp::cleanup()  
{  
console() \<\< “#OK cleanup” \<\< std::endl;  
exit(0);  
}

Now repeat the test, and you should see this in the console window:

**#OK window closed, exiting**  
**#OK cleanup**

If instead you type command-Q, it only calls cleanup().

Now I can click the red dot or type command-Q with aplomb.
