# Destructor not firing on Mac App.Close event

**URL:** <https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440>\
**Category:** General\
**Created:** [February 20, 2019, 9:26am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440 "2019-02-20T09:26:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [February 20, 2019, 9:26am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/1 "2019-02-20T09:26:51Z")

</div>

Please see sample project:  
[https://drive.google.com/open?id=1Xb\_pPOYBfp9P\_JnG8YTf9E\_DMoSIt\_FT](https://drive.google.com/open?id=1Xb_pPOYBfp9P_JnG8YTf9E_DMoSIt_FT)

Start the project and hit the close button of the window.

On Windows the Destructor or myClass is firing and the MsgBox is displayed.  
On Mac this doesn’t happen.  
Is this a bug or am I missing something?

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [February 20, 2019, 10:01am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/2 "2019-02-20T10:01:31Z")

</div>

If you add this to the Window1.Open() event:

`if app.cls <> nil then
  msgbox "cls is not nil"
else
  msgbox "cls is nil"
end if
`

You will get a ‘CLS is not nil’ message.  
Then, when you close the window, app.autoquit kicks in.  
And the destructor message is seen.

It could be that the compiler understands that cls is never used, and optimises it out…

edit:  
I get the destructor message even without the code above, in debug mode at least…

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [February 20, 2019, 10:23am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/3 "2019-02-20T10:23:21Z")

</div>

Well in real “myClass” is a class for loading and saving local settings (such as window positions).  
This class is used very often in our projects but the Destructor doesn’t get fired on App.Close.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [February 20, 2019, 10:44am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/4 "2019-02-20T10:44:16Z")

</div>

Bug

---

<div class="post-metadata">

**Author:** ![StefanA](https://forum.xojo.com/user_avatar/forum.xojo.com/stefana/32/286_2.png) [@StefanA](https://forum.xojo.com/u/StefanA)\
**Post date:** [February 20, 2019, 10:49am UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/5 "2019-02-20T10:49:03Z")

</div>

\<[https://xojo.com/issue/54969](https://xojo.com/issue/54969)\>

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:33pm UTC](https://forum.xojo.com/t/destructor-not-firing-on-mac-app-close-event/47440/6 "2020-10-29T19:33:50Z")

</div>


