If ESC will close the window, you may lose your script and this might be annoying. So we are reluctant to close window on ESC
then in any case it’s better to add confirmation “do you really want to close the code editor?”