Added check to prevent crash when popping to a VC

If you try to pop to a view controller that is already at the top of
the stack, you get a crash. This makes sure that you aren’t trying to
do that by quitting if the view controller to pop is the last
controller.