#include "map_window.h" /* for map_center() */
 #include "wincontrol.h" /* struct WinConf, init_winconfs(), init_wins(),
                          * sorted_wintoggle_and_activate(), get_win_by_id(),
-                         * get_winconf_by_win(), toggle_window()
+                         * get_winconf_by_win(), toggle_window(),
+                         * get_next_winconf_id()
                          */
 #include "windows.h" /* struct Win, make_pad(), suspend_win(), free_win() */
 #include "world.h" /* global world */
     {
         w_p = world.wmeta.active;
         suspend_win(w_p);
-        free_win(w_p);
+    }
+    char id;
+    while (0 != (id = get_next_winconf_id()))
+    {
+        free_win(get_win_by_id(id));
     }
     delwin(world.wmeta.pad);
     make_pad();
 
 /* Get (Win->draw) function identified by "c"; NULL if c not mapped to one. */
 static void * get_drawfunc_by_char(char c);
 
-/* Iterate over chars of world.winconf_db.winconf_ids array. Restart after \0.*/
-static char get_next_winconf_id();
-
 
 
 static char * string_prefixed_id(char * prefix, char id)
 
 
 
-static char get_next_winconf_id()
-{
-    static uint8_t i = 0;
-    char c = world.winconf_db.winconf_ids[i];
-    if (0 == c)
-    {
-        i = 0;
-        return c;
-    }
-    i++;
-    return c;
-}
-
-
-
 extern struct WinConf * get_winconf_by_win(struct Win * win)
 {
     uint8_t i = 0;
 
 
 
+extern char get_next_winconf_id()
+{
+    static uint8_t i = 0;
+    char c = world.winconf_db.winconf_ids[i];
+    if (0 == c)
+    {
+        i = 0;
+        return c;
+    }
+    i++;
+    return c;
+}
+
+
+
 extern void save_win_configs()
 {
     char * f_name = "save_win_configs()";
 
  */
 extern void sorted_wintoggle_and_activate();
 
+/* Iterate over chars of world.winconf_db.winconf_ids array. Restart after \0.*/
+extern char get_next_winconf_id();
+
 /* Save world.winconfs, visible window chain and active window selection to the
  * respective configuration files in client config windows directory.
  */