[B]Closebutton to terminate Flash app[/B]

Closebutton to terminate Flash app

I wonder how one can do the following:

How do I add a Close button to my Flash application? So that the app is terminated upon a click - and also if certain criteria are met (like totalsystememory size too large) that this be done with As3 calling some “Terminator function”
It seems there is a way out there as sold below;

pls advice,
Jaxz