Applescript Crashing on Infinite Loop
Like all while/do (Applescript repeat) loops, you must ensure a condition is met for it to exit.

How do you ensure that a condition will be met and not go on infinitely?  From what I can tell you have a window that can contain "Start MP3" or "Stop Loop."  What if it contains "I love balloons" or is blank?

You haven't created any logic for this (error trapping) so this loop will repeat until the window meets the condition to stop. 

To prevent that you to put in a fail safe that sets the condition that stops the loop.  You can do this  by adding a counter and checking the counter against a predetermined value that will force condition that stops the loop to become true.

For example, we set a limit that the loop will run 10 times:

set count to 0

repeat until (stopString = "stop")

    ...


    if count &gt; 10 then
        set stopString to "stop"
    end if

    set count to count + 1

end repeat