Pose mode -> Object Mode?

I’m writing python to duplicate an armature, and i found Window.EditMode(x) to set edit on/off mode, but if an armature is selected there is a PoseMode as well…and you cannot duplicate an armature if it is pose mode.

How do I set the Window(?) to Object mode, regardless of what is selected and what mode it is in or came from? And like a mesh could go from Sculpt to Edit mode, and I want object mode…!? help?