What are you supposed to do when you make an error typing in the Ruby console? I am on p.137 in Simply Rails and made a typo. What do you do to get back on track after that? I have attached a screenshot.
In your example, once you get back to the console with a line starting >> you should be able re-enter the command with the correct coding. Re-entering should overwrite the previous entry.
To leave the console, enter exit at the console prompt (>>).
If you have a console open and have changed code in your editor, the change will not take immediate effect. You either have to exit or re-enter the console, or more usefully, enter reload! at the console prompt.
In the example you give, the problem was that you'd open a new text input (with the initail ') and hadn't closed it. The system was letting you enter more text until you closed the text entry or caused an error. So one way to get out of the problem would just have been to enter another closing ' and then carriage return. However, often you can get stuck and usually either ctrl-z or ctrl-c or a combination of both.
In the attached screen shot, I've replicated your problem in irb. I then used both ways to return to a standard prompt. In the second example, it was a combination of a ctrl-c and then a ctrl-z that got me back to >