Handle the navigation stack.