As said earlier just press Ctrl+C to terminate the program(and the loop).If memory usage is high enough,then the system will crash.It is basically harmless because it only uses up memory but forces an immediate shutdown of the system.