Called by the framework when a main frame window is processing WM_CLOSE message.
The default implementation saves the main frame window state.