I can’t express how strongly I wouldn’t recommend this – just DON’T
This will get your app rejected from the App Store in the Apple App Store Review Process.
If you insist on it though you could use exit(0);
If the user wishes to exit your app they have the Home button at the bottom of the device so there is no need to do this at all, it will create confusion and and look as if the app has crashed.
See this, it states.
There is no API provided for gracefully terminating an iOS application.
Warning: Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen.
So this means there is no Public API that will allow you to do this gracefully so your app would get rejected under
2.5 – Apps that use non-public APIs will be rejected
From source Apple Review Guidelines
Basic definition of exit()
exit
. The exit statement terminates your program with an exit code. Its prototype isvoid exit(int exitcode);
exit
is used by some operating systems and may be used by calling programs. By convention, anexit
code of0
means that the program finised normally, and any other value means that some error or unexpected results happened.
Also another source that says don’t use it is here. That is basically all of the Apple Documentation saying under no circumstance should you be exiting the app programmatically.
9
solved Exit iPhone app, from tab bar controller? [duplicate]