The easiest method is to use FileMaker Advanced's Script debugger. You can abort any running script by clicking the red X in that window. You can open the file and then open the debugger in order to cancel the script. You can even just edit the open script to fix the problem now that it's showing in the debugger. (This is one of many reasons why anyone making design changes in a FileMaker file should be using Advanced instead of Pro.)
If you do not have FileMaker Advanced, but you have at least one other script defined in the file, you can use this trick to open the file without tripping the script trigger for you never ending script:
Create a new file. In that file define a script with a single script step: Perform Script. use the options for that script step to perform the "other script" in your original file. Set it to perform any script in the other file that is "safe"--probably anything but the one with the infinite loop and you'll have opened the file without tripping the trigger.
You may also find the following thread of interest: Had you used it, you would also have the option of being able to open a minutes old backup copy of your file as a way to get around this problem: Saving Sequential Back Ups During Development