This implements a reasonable facsimile of going back on Android. The back button first goes back in a history of visited pages. When there's no history left, it closes the app. Fixes #3816.