CUDA, QT UI CUDA send some specal msg to HOST when the program ends?

Dear all,

I am building a UI with Qt for a CUDA application under WinXP,
my procedure is:
(1) build the CUDA procedure to a dll/lib.
(2) link the UI program to call the CUDA procedure.

It works fine so far( I mean, the UI does take control the execution of the CUDA procedure ).
But the interesting part is: after the second time the CUDA execution is done, the UI is killed automatically.
(I press the button to call the cuda procedure, first time after the execution is done, the result is written out,the button is released,
then I press the button again to call the cuda procedure, after the execution is done, the result is written out, the UI is killed too. And seems the control is not given back to my UI program back, because the second time, the break point is even not reached)

void uistart()
{
runSimulation(m_energy, m_hflag, m_hratio, m_nblocks, m_nthreads);
printf(“testing!”); // breaking point here, it did not stop on second time before the ui is killed
}

can anybody give some hint about it?

Best