Make sure that quitting time is followed by happy hour.
Generally, you don’t do anything special in a LabVIEW program to quit; when it runs out of things to do, it terminates. (Quite clever, that). Your program has a loop waiting on the user to do something: when the QUIT button is clicked, the loop stops. If that is the last thing in your VI, then the VI terminates, and it’s left on the screen for you. Usually, that’s what you want; you quit because you’re ready to add the next feature, or because you decided that the purple font on the pink background was too gaudy, or because you need to find out why the temperature shows -1.33e+44 degrees.
But if you compile your program into an executable, the same thing happens (the main window hangs around), but that’s usually NOT what you want here. The user pressed the QUIT button – why doesn’t it quit? Most programs make their windows disappear when the user quits, and yours doesn’t do that. You might understand that it really did quit and the window’s just hanging around waiting for you to close it, but unless you enjoy the tech support calls that result, you should consider doing something about it.
To get that window to close in an executable, you have to QUIT LABVIEW. Find that function on the APPLICATION CONTROL palette and put it where it will execute when everything in your program is safely shut down.
The trouble is, it will ALSO quit LabVIEW when you’re in the development system. That’s nice in the executable, as all your windows go away just like they’re supposed to. But in the development system, you don’t want to quit developing; you want to stop your program from running.
One easy way to satisfy both requirements is to use the ROOT FOLDER vi. It has an output called NOT IN LIBRARY which connects to the QUIT? input on the QUIT LABVIEW function. If you’re already using that VI to ascertain your root folder, then just remember the initial value of NOT IN LIBRARY. Or call it again at quitting time; it’s small and fast.
That way, you close up the windows in an executable, but leave it ready in the development environment, and you don’t have to set conditionals, or remember to set a boolean flag in your code. It works without change in either situation.
Also, you should vote for this idea, so that we never have to deal with again –
http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-an-easily-accessible-way-to-close-an-application/idi-p/1108102