Posthumous divorce’s technical but less popular name is a “notification of marital relationship termination” (inzoku kankei shuryo todoke) which means one is officially severing ties with the family of a deceased spouse. What’s particularly strange about it is that it doesn’t really serve any purpose for a vast majority of people aside from a government-approved official statement that someone finds their in-laws unbearable.
But you have to stray married to your in-laws if you divorce your spouse.
It’s a custom to protect people from unnecessary not-theirs-pet loss just because they live with the other family.