   "Populate the Rdebug 'Debugger' menu."
   (let ((menu (make-sparse-keymap))
         (common-map (make-sparse-keymap)))
-    ;; Use a simple common map to find the best key sequence to display in menu.
+    ;; Use a simple common map to find the best key sequence to
+    ;; display in menu.
     (rdebug-populate-common-keys common-map)
 
     (define-key map [menu-bar debugger] (cons "Debugger" menu))
 
     (define-key menu [break-delete]
-      (rdebug-menu-item common-map "Delete breakpoint" 'gud-remove))
+      (rdebug-menu-item common-map "Delete breakpoint" 'gud-remove
+                        :enable '(get-buffer-process gud-comint-buffer)))
 
     (define-key menu [break]
-      (rdebug-menu-item common-map "Set breakpoint" 'gud-break))
-
-    (define-key menu [finish] (rdebug-menu-item common-map "Step out" 'gud-finish))
-    (define-key menu [step]   (rdebug-menu-item common-map "Step into" 'gud-step))
-    (define-key menu [next]   (rdebug-menu-item common-map "Step over" 'gud-next))
-    (define-key menu [cont]   (rdebug-menu-item common-map "Continue" 'gud-cont))
+      (rdebug-menu-item common-map "Set breakpoint" 'gud-break
+                        :enable '(get-buffer-process gud-comint-buffer)))
+
+    (define-key menu [finish]
+      (rdebug-menu-item common-map "Step out" 'gud-finish
+                        :enable '(get-buffer-process gud-comint-buffer)))
+
+    (define-key menu [step]
+      (rdebug-menu-item common-map "Step into" 'gud-step
+                        :enable '(get-buffer-process gud-comint-buffer)))
+
+    (define-key menu [next]
+      (rdebug-menu-item common-map "Step over" 'gud-next
+                        :enable '(get-buffer-process gud-comint-buffer)))
+
+    (define-key menu [cont]
+      (rdebug-menu-item common-map "Continue" 'gud-cont
+                        :enable '(get-buffer-process gud-comint-buffer)))
+
+    (define-key map [menu-bar debugger line1] '(menu-item "--"))
+
+    (define-key menu [stop]
+      (rdebug-menu-item
+       common-map "Stop the debugger" 'rdebug-quit
+       :enable '(get-buffer-process gud-comint-buffer)))
+
     (define-key menu [start]
       (rdebug-menu-item common-map "Start the debugger" 'rdebug))
 
+    (define-key map [menu-bar debugger line2] '(menu-item "--"))
+
+    ;; Placeholder used when populating the menu of the secondary buffers.
     (define-key menu [placeholder] nil)
 
     ;; --------------------


      (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
              rdebug-debugger-support-minor-mode-map-when-active)
      (when rdebug-many-windows (rdebug-setup-windows-initially))

      (run-hooks 'rdebug-mode-hook))))


(defun rdebug-quit ()

      (when rdebug-buffer (kill-buffer rdebug-buffer))
      (rename-buffer rdebug-buffer-name)

      (rdebug-common-initialization)

      ;; Setup exit callback so that the original frame configuration
      ;; can be restored.
      (let ((process (get-buffer-process gud-comint-buffer)))
