When stopping a direct edit thread, the call to stop the observer raises the following errors:
ValueError: PyCapsule_GetPointer called with invalid PyCapsule object
SystemError: <built-in function stop> returned a result with an error set
We need to surround the call with a lock.