Fix TextEditor close bug