We simply need to fix SpawnProcess._cancel to call the cgroup process cleanup code.
There's a patch in the following branch: https://github.com/zmedico/portage/tree/bug_566414 I've posted it for review here: https://archives.gentoo.org/gentoo-portage-dev/message/cb6eb2c0398b3ea919ab3b2d2c6863ee
This is in the master branch: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fc78181d856ef0ecf6fa21262cc87fe71426d8e3
Fixed in 2.2.26.