Fix crash that may occur while closing an edit window.