I have a hunch it's something to do with "commit record". The "commit record" script line may be necessary to force field changes to be stored and evaluated correctly. If the "exit loop" condition is not working, it may be because the field it is looking at has not been committed.
The first thing you need to look at is the condition that the "exit loop" script step is testing. Monitor the fields being referred to by the exit condition while running the script debugger. The aim of this is to see why the exit loop condition is not being met. If you're using FileMaker Pro Advanced, the Data Viewer will come in handy, otherwise just slap the relevant fields on your layout for the time being.
Thank you, Kevin, for the suggestion. Much appreciated!