But you can't type commands (or even open your inventory, or hit [ESC] to disconnect) while inside the portal.
@OP, have you tried just punching your way out? It will take a very, very long time to break the obsidian (4m10s, according to the wiki) without a diamond pick, but you can break it, eventually (unless it's protected by a worldguard plugin or whatever. Then you really are screwed.)
Village Mechanics: A not-so-brief guide - Update for 1.4! Added subsection on iron farming to the iron golems section. Only ten villagers required to spawn golems (down from sixteen)! Put to rest the "facing doors cancel each other" myth!