Here are a few more details.
A typical CVI program uses RunUserInterface to start the user interaction, then uses QuitUserInterface to end the user interaction and close the open windows.
If you have a Quit button on your panel: In the UI Editor, if you double click on a blank spot on your main panel (to edit the panel), you'll see a Panel Setting for Close Control. Use this if you have a command button you want to use to quit your application. The callback for this button will need to call QuitUserInterface in the case for EVENT_COMMIT. If you select this control as the panel Close Control before running the code generator, the call QuitUserInterface(0); will automatically be included in the callback. If you do it after the fact, you can include QuitUserInterface(0); in the case for EVENT_COMMIT. The X (Close) button on the window will know which callback to use if the control is identified as the Close Control.
Note: the CVI controls menu has a Quit control which saves you a couple of steps. In the UI Editor, right-click on a blank spot on the panel (to get the control menu), then click on Custom Controls, then Quit button. You'll get a control which already has a callback function name assigned to it. If you add this custom control before running the code generator, this control will be assigned as the default Close Control so the code generator will automatically add QuitUserInterface to the callback.
If you don't have a Quit button and only want to use the X button on the window, you need to generate a panel callback. In the UI Editor, double click on a blank spot on your main panel (to edit the panel). Enter a function name (e.g. panelCallback) in the box labeled Callback Function and click OK. In the UI editor, click on Code >> Generate >> Panel Callback. Then click on Code >> View >> Panel Callback. In the case for EVENT_CLOSE, add a call to QuitUserInterface(0);