Fix crash when closing edit window.