This has happened to me as well, exact same way, except i was in a castle. My faction made peace with an unrelated faction, and it kicked me out of a castle while I was defending.
I have had a couple of multi-phase battles that resolve correctly, and give me the correct loot. That is only about 1 out out of 20 battles though, and I never get the troop XP, it treats it as if I was the one retreating.