Hi there, this is my first contribution to Blender, so I apologize before hand if something isn't correct!
This was caused by the tooltip clear being called when a there was no window in the wm property of the Context.
Tested it by replicating the same behaviour as described in the task, and using Blender normally after that. The output of all actions done were expected behaviour, no crashes.
Hope this fixes the problem! :)