Close app programmatically

Hi. I’m trying to find a way to keep a nice user flow going. Here’s my context:

  1. User imports a backup file via airdrop, from a laptop to the mobile.
  2. The app opens and asks for a password to import and decrypt the file.
  3. The user decides to cancel instead, so taps the cancel button.

How do I then exit the program in a nice way? There seems to be no way to programmatically tap the Home Button. I could pop up a message alert telling the user to tap the home button themselves, but it would be better if that doesn’t have to be.

My issue is probably more to do with openURLContexts. When the app is launched afresh, from the backup file, openURLContexts does not run. It only runs when the app is launched from the background. Does anyone know how to make sure that openURLContexts runs?