Properly deregister event handlers to avoid executing events on obsolete...

Properly deregister event handlers to avoid executing events on obsolete documents when editor is restarted.