Fix a circular reference that cause the app destructor from not being called

This needs to be tested on Windows