Rare exception when terminating processes

In some corner cases, we are experiencing the symptoms described in this python upstream bug report

This is mostly harmless, but is nevertheless a stack trace thrown at the user for no good reason, e.g.:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.5/multiprocessing/util.py", line 288, in _exit_function
    _run_finalizers(0)
  File "/usr/lib/python3.5/multiprocessing/util.py", line 248, in _run_finalizers
    items = [x for x in list(_finalizer_registry.items()) if f(x)]
RuntimeError: dictionary changed size during iteration