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 https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload

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