We'd probably answer that question by answering what does it actually mean for a Pokémon to be "Boxed".
In my headcanon, it works as in Legends Arceus. Pokémon are inside their Pokéballs when traveling with their trainers, and those who don't are teleported to pastures or something like that, where they can walk, sleep, eat, and interact with each other. Makes no sense for Pokémon to be held in actual boxes inside a PC, especially since that would mean that countless Pokémon would never see the light anymore after caught, which sounds rather disturbing.
So, if a trainer dies, whatever people are in charge of the pastures would sent all their Pokémon back into the wild or see if other trainers want to take care of them instead.
I guess if a trainer dies while traveling with six Pokémon, someone would have to retrieve the Pokéballs because otherwise those poor creatures will be stuck inside balls forever... well, not really, because Pokémon can actually go outside their Pokéball on their own, they just normally have no reason to do so.