cmd/jujud: upgrade mode end fix

Fixed a case where upgrade mode wasn't being stopped when it should. This is actually almost impossible to hit in practice but good to fix anyway. 

Added a unit test to cover this case.