OK, I think I've missed something. How are the arrow keys involved?
...ah, I may have an idea. You probably want a
key.clear at the bottom of your main loop, right before you exit. This clears the keyboard buffer. Otherwise, all those key presses you were using for movement have just piled up and then spew into the command console.
(I see some of the demos do this and some do not. I should perhaps be more consistent about it.)
I don't feel like this is really a command-history issue, though; you'd have a similar problem if you used WASD for movement, or anything else.