--- mythgallery/mythgallery/iconview.cpp.orig	2010-03-29 16:19:43.134252778 +0200
+++ mythgallery/mythgallery/iconview.cpp	2010-03-29 18:29:10.162246017 +0200
@@ -461,8 +461,26 @@
                handled = false;
        }

-        if (action == "ESCAPE")
-            handled = HandleEscape();
+        if (action == "ESCAPE") 
+        {
+            if (!GetMythMainWindow()->IsExitingToMain()) 
+            {
+                handled = HandleEscape();
+            } 
+            else 
+            {
+                while (true) 
+                {
+                    QDir currentDir(m_currDir);
+                    QDir rootDir(m_galleryDir);
+                    if (currentDir != rootDir) 
+                        HandleSubDirEscape(m_galleryDir);
+                    else 
+                        break;
+                }
+                handled = HandleEscape();
+            }
+        }
    }

    if (!handled && MythScreenType::keyPressEvent(event))
