The Talmud Yerushalmi and Talmud Bavli quote instances the restriction of a Kohen to defile himself to a corpse were waived.
Alternatively, it is recorded that some renowned tzaddikim (righteous rabbinic leaders) deliberately expressed to those present at their time of their imminent passing that those Kohen's (or pure vessels) present should make an immediate exit (be removed from the premises) so as not to become 'ttammei (defiled).