Can the duchy with the Stronghold do anything though? Ie, legally switch to a different realm? It leaves the realm with a city.
Why not? So long as the realm is left with at least one city/stronghold, I don't see why any duchy would not be allowed to switch allegiance.
For the most part, there are only two significant differences between cities and strongholds:
1) A stronghold does not have a bank, unless it's the capital.
2) A stronghold cannot secede. The duchy that is seceding must have a city in it.