When you have any breakpoints in the code, Matlab runs in debug mode. As a side-effect this disables the JIT acceleration and the code might run 4 or 100 times slower. Therefore the debug mode should be active only for debugging, but not for an interactive control of a productive program execution. It is too dangerous to insert a key by accident (as in your case) and confuse the system of computer and user. You are right: If you press "exit debug mode" the complete program is stopped and all changes are lost.
The formerly existing breakpoints work even if you have changed the file but did not save it. Then you cannot set new breakpoints and if you have inserted new lines, the editor might look like it stops in the wrong lines, because it uses the breakpoint-lines of the formerly saved code. This does not impede the porgram execution, only the display in the editor, but this is confusing enough.
My suggestion is: Do not run your code in debug mode for productive work.
Best Answer