Throw a nicer exception if an invalid pid is given
Fixup the stopping of dependent capabilities