Handle back button properly when no more pages are left

Change-Id: I8c5dd5366cff872530b331b42ed5892929d7bb0b