A duchy cannot secede if it contains the realm capital.
I remember during the realm crisis after the war, egamma character(duke of Oritolon city which is Oritolon realm capital city) changed allegiance to Lukon realm. At that time, Oritolon realm still had Alebad city, so it is not considered as last city. A duchy can change side but cannot secede on its own. Not sure if this can help.