Added functions to exit app and to handle the back key press