diff --git a/.gitignore b/.gitignore
index 5b45fd4..f473653 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,5 +28,13 @@ __pycache__
 .pytest_cache
 .python-version
 venv*/
-.idea/
 .mypy_cache/
+
+# jetbrains ide stuff
+*.iml
+.idea/
+
+# vscode ide stuff
+*.code-workspace
+.history
+.vscode
diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py
index 8e3dd96..ba12e3e 100644
--- a/IPython/core/debugger.py
+++ b/IPython/core/debugger.py
@@ -101,7 +101,6 @@ All the changes since then are under the same license as IPython.
 #
 #*****************************************************************************
 
-import bdb
 import inspect
 import linecache
 import sys
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index ea9f631..371a3da 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -14,6 +14,7 @@
 import abc
 import ast
 import atexit
+import bdb
 import builtins as builtin_mod
 import dis
 import functools
@@ -3403,6 +3404,11 @@ class InteractiveShell(SingletonConfigurable):
                 result.error_in_exec = e
             self.showtraceback(exception_only=True)
             warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
+        except bdb.BdbQuit:
+            etype, value, tb = sys.exc_info()
+            if result is not None:
+                result.error_in_exec = value
+            # the BdbQuit stops here
         except self.custom_exceptions:
             etype, value, tb = sys.exc_info()
             if result is not None: