I’ve coded myself into plenty of long running or infinite loops while testing. Sometimes, as you suggest, in order to figure out what is going on, I may change it to a for loop with enough cycles to describe the issue, but there is nothing wrong with a while True loop as long as you have your exit plan in place.
True, there is no built-in way I know of that will kill your script and keep Rhino running if you get into trouble (that would be nice tough). I have used the escape_test in the past with success (sometimes it takes 2 escape presses).
If interested, here are some things I have discovered while dealing with the UX in these situations:
Rhino.RhinoApp.Wait() can help help with ‘not responding’ windows messages, although where to put it seems to be something of an art, to me at least.
Periodic prints, doc updates and sc.doc.Views.Redraw() can also provide feedback in long running loops. Maybe updating every 100 or 1000 or n cycles is more appropriate than every singe loop.
rs.StatusBar#######() functions are available if you can estimate completeness or some other scalar metric. Updating this seems to keep Rhino ‘alive’ pretty well.
Conduits are a little more complex but are another way (my favorite) to provide graphical updates on loop progress as well, if the loop is updating/generating geometry.