The Stop function I mentioned operates the same way as the front panel abort button but you have to use it correctly. You have to design your program to properly terminate on an error condition. If you use a state machine architecture, on an error do whatever cleanup is necessary like closing files and references first and then terminate the while loop. If you have a series of VIs connected by the error in/out clusters, you could surround the code by a case statement. Only if there is no error in would it get executed. Some types of LabVIEW code are difficult to exit prematurely like a sequence structure or a for loop. If you posted an example of your program, I or someone use could get a little more specific. There's also a lot of examples
on user interface programming that you might want to look at. Check the shipping examples and the development library at NI's Developer Zone.