Added a check for when the app should quit on the back key being pressed.