Is it possible to detect if an OW app window is closed?

I want to catch close event: when the user clicks on the close button. is it possible? is it possible to detect if the window is closed?
Maybe something like

In case you have more than one window, you can access the window object of any window via
You can also try to use: it might suffice.