+static gboolean
+modest_hildon2_window_mgr_close_all_but_initial (ModestWindowMgr *self)
+{
+ ModestWindow *top;
+
+ /* Exit if there are no windows */
+ if (!modest_window_mgr_get_num_windows (self)) {
+ g_warning ("%s: unable to close, there are no windows", __FUNCTION__);
+ return FALSE;
+ }
+
+ /* Close active modals */
+ if (!_modest_window_mgr_close_active_modals (self)) {
+ g_debug ("%s: unable to close some dialogs", __FUNCTION__);
+ return FALSE;
+ }
+
+ /* Close all but first */
+ top = modest_window_mgr_get_current_top (self);
+ if (!MODEST_IS_ACCOUNTS_WINDOW (top))
+ close_all_but_first (NULL);
+
+ /* If some cannot be closed return */
+ top = modest_window_mgr_get_current_top (self);
+ if (!MODEST_IS_ACCOUNTS_WINDOW (top)) {
+ g_debug ("%s: could not close some windows", __FUNCTION__);
+ return FALSE;
+ }
+
+ return TRUE;
+}