Unfortunately, I didn't take into account that in the web version, pressing ESC while in fullscreen mode prioritizes exiting fullscreen and blocks in-game interactions. Closing the document does work if you press ESC again after exiting fullscreen, since the game then recognizes it as an in-game input, but that's obviously not how it's supposed to work.
I've already changed the key to ENTER, but I won't be able to release the update until after the rating phase.
In the meantime, the Windows version would be an alternative, as it doesn't have this issue. Otherwise, you can work around it by exiting fullscreen, pressing ESC again to close the document, and then going back into fullscreen, or playing without fullscreen, but I don't really expect anyone to actually go through all that hassle.
Sorry for the inconvenience, and thanks for reporting the issue!