Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp	(revision 25143)
+++ libs/libmythtv/tv_play.cpp	(working copy)
@@ -3469,6 +3469,22 @@
 
 void TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
 {
+    QStringList actions;
+    bool handled = GetMythMainWindow()->
+        TranslateKeyPress("TV Playback", e, actions, false);
+    if (handled)
+        VERBOSE(VB_IMPORTANT,
+                "ProcessKeypress(): "
+                "TranslateKeyPress() unexpectedly returned true");
+    bool isJumpingToMain = has_action("ESCAPE", actions) &&
+        GetMythMainWindow()->IsExitingToMain();
+    unsigned iterations = 0;
+    // Set a limit on the number of iterations in case pressing escape
+    // repeatedly somehow gets into a loop.
+    const unsigned kMaxIterations = 10;
+    do {
+        ++iterations;
+
     bool ignoreKeys = actx->IsNVPChangingBuffers();
 #if DEBUG_ACTIONS
     VERBOSE(VB_IMPORTANT, LOC + QString("ProcessKeypress() ignoreKeys: %1")
@@ -3481,8 +3497,7 @@
         idleTimerId = StartTimer(db_idle_timeout, __LINE__);
     }
 
-    QStringList actions;
-    bool handled = false;
+    handled = false;
 
     if (ignoreKeys)
     {
@@ -3490,20 +3505,23 @@
                   "TV Playback", e, actions);
 
         if (handled || actions.isEmpty())
-            return;
+            continue;
 
         bool esc   = has_action("ESCAPE", actions);
         bool pause = has_action("PAUSE",  actions);
         bool play  = has_action("PLAY",   actions);
 
         if ((!esc || browsemode) && !pause && !play)
-            return;
+            continue;
     }
 
     OSD *osd = GetOSDLock(actx);
     if (osd && osd->DialogVisible())
     {
-        osd->DialogHandleKeypress(e);
+        if (GetMythMainWindow()->IsExitingToMain())
+            osd->DialogQuit();
+        else
+            osd->DialogHandleKeypress(e);
         handled = true;
     }
 
@@ -3530,7 +3548,7 @@
     ReturnOSDLock(actx, osd);
 
     if (handled)
-        return;
+        continue;
 
     // If text is already queued up, be more lax on what is ok.
     // This allows hex teletext entry and minor channel entry.
@@ -3542,10 +3560,11 @@
         if (ok || txt=="_" || txt=="-" || txt=="#" || txt==".")
         {
             AddKeyToInputQueue(actx, txt.at(0).toLatin1());
-            return;
+            continue;
         }
     }
 
+    bool should_continue;
     // Teletext menu
     actx->LockDeleteNVP(__FILE__, __LINE__);
     if (actx->nvp && (actx->nvp->GetCaptionMode() == kDisplayTeletextMenu))
@@ -3556,14 +3575,18 @@
 
         if (!handled && !tt_actions.isEmpty())
         {
+            should_continue = false;
             for (int i = 0; i < tt_actions.size(); i++)
             {
                 if (actx->nvp->HandleTeletextAction(tt_actions[i]))
                 {
                     actx->UnlockDeleteNVP(__FILE__, __LINE__);
-                    return;
+                    should_continue = true;
+                    break;
                 }
             }
+            if (should_continue)
+                continue;
         }
     }
 
@@ -3576,14 +3599,18 @@
 
         if (!handled && !itv_actions.isEmpty())
         {
+            should_continue = false;
             for (int i = 0; i < itv_actions.size(); i++)
             {
                 if (actx->nvp->ITVHandleAction(itv_actions[i]))
                 {
                     actx->UnlockDeleteNVP(__FILE__, __LINE__);
-                    return;
+                    should_continue = true;
+                    break;
                 }
             }
+            if (should_continue)
+                continue;
         }
     }
     actx->UnlockDeleteNVP(__FILE__, __LINE__);
@@ -3592,7 +3619,7 @@
               "TV Playback", e, actions);
 
     if (handled || actions.isEmpty())
-        return;
+        continue;
 
     handled = false;
 
@@ -3618,7 +3645,7 @@
 #endif // DEBUG_ACTIONS
 
     if (handled)
-        return;
+        continue;
 
     if (!handled)
     {
@@ -3635,6 +3662,10 @@
             }
         }
     }
+
+    } while (isJumpingToMain &&
+             exitPlayerTimerId == 0 &&
+             iterations <= kMaxIterations);
 }
 
 bool TV::BrowseHandleAction(PlayerContext *ctx, const QStringList &actions)
