Closing the window app from inside

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

Yes, use:
htmlexe.RunHEScriptCode('ExitPublication;');