The same way WP warns you if you try and close a page that you haven’t saved or updated after changes are made. and if you don’t want to monitor that even a warning everytime that just says “are you sure you want to leave” would be nice to prevent accidently closing the editor.