Repository: spyder-ide/spyder

Issue:
Console won't close
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

So I opened a project that has a venv python virtual environment + conda environment. I run a script and am using Ipython. For whatever reason I want to reset the console. Spyder will not let me close the console 

### Traceback
```python-traceback
  File "d:\john huang\python\microblog\venv\lib\site-packages\spyder\plugins\ipythonconsole\plugin.py", line 995, in close_client
    client.shutdown()
  File "d:\john huang\python\microblog\venv\lib\site-packages\spyder\plugins\ipythonconsole\widgets\client.py", line 506, in shutdown
    self.shellwidget._pdb_history_file.save_thread.stop()
AttributeError: 'NoneType' object has no attribute 'stop'
```

## Versions

* Spyder version: 4.1.2 
* Python version: 3.7.7
* Qt version: 5.12.8
* PyQt5 version: 5.12.3
* Operating System: Windows 10

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
paramiko >=2.4.0               :  2.7.1 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.1 (OK)
qtconsole >=4.6.0              :  4.7.2 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
sphinx >=0.6.6                 :  3.0.1 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.0 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  None (OK)
numpy >=1.7                    :  None (OK)
pandas >=0.13.1                :  None (OK)
scipy >=0.17.0                 :  None (OK)
sympy >=0.7.3                  :  None (OK)
```



Discussion:
@steff456, an easy one for you. Simply catch that error and pass on it.

Resolving patch:
diff --git a/spyder/plugins/ipythonconsole/widgets/client.py b/spyder/plugins/ipythonconsole/widgets/client.py
--- a/spyder/plugins/ipythonconsole/widgets/client.py
+++ b/spyder/plugins/ipythonconsole/widgets/client.py
@@ -503,7 +503,10 @@ def shutdown(self):
         if self.get_kernel() is not None and not self.slave:
             self.shellwidget.spyder_kernel_comm.close()
             self.shellwidget.spyder_kernel_comm.shutdown_comm_channel()
-            self.shellwidget._pdb_history_file.save_thread.stop()
+            try:
+                self.shellwidget._pdb_history_file.save_thread.stop()
+            except AttributeError:
+                pass
             self.shellwidget.kernel_manager.stop_restarter()
         self.shutdown_thread = QThread()
         self.shutdown_thread.run = self.finalize_shutdown


Test patch: