Closing the app from inside

hello, is there any trick to close the app from javascript function for example ?

Yes, use this single line of code:
exeoutput.RunHEScriptCode('ExitPublication;');