How to close your app programmatically
exit (0); will do the trick. Shutdown happens immediately. If you do this in a live app it’s probably a good idea to let the user know and wait for a button click, or perhaps integrate a timer before the shutdown occurs.