Prevent transitioning to nonexistent pages on ends