This is now fixed in GitLab 17.0+ with GitLab Runner 16.9 and above.
https://about.gitlab.com/releases/2024/05/16/gitlab-17-0-released/#always-run-afterscript-commands-for-canceled-jobs