I couldn't make out a lot of what you were saying so I'll just answer your question in general.
If you want any control, such as a button, to stop the user interface, you would just call QuitUserInterface(0) in that callback function. When you create a UIR file, then generate the code for it by selecting Code->Generate->All Code..., you will be asked which controls should call QuitUserInterface, and CVI will automatically insert those function calls in the callbacks for you.
As for the X button in the title bar of the window, that is setup in the panel settings in the UIR editor. Double-click on the panel and you will see a Close Control: entry in the Edit Panel screen. Whatever control is selected here, is the control callback that is executed whe
n the X button on the title bar is pressed. If you select "None" for the Close Control:, the X button on the title bar will not do anything.
Best Regards,
Chris Matthews
National Instruments