When I'm editing in nano, after a while I get the command console inside the editor. I attach an image with the nano problem
I know the error that caused the nano to close automatically and leave me in the command console. The problem is that the file I was accessing was in the container and the status of the container was "Up to 2 minutes (health: start)", which caused the container to restart from time to time and for each restart to exit the editor "nano".
I could be wrong (see my comments asking for clarification), but I'm guessing maybe you're typing in the main text area, and you pressed Ctrl+w, or another keyboard shortcut that invoked the option to search. Just press Ctrl+c to cancel and it should take you back.
Ctrl+c doesn't break out of the program, so you don't need to worry about that happening. It's what you press to cancel stuff in Nano.