However I'd prefer to do it from the activity plugin itelf. Apologies if it is obvious but I'm just not seeing it.
Is this possible?
Take a look at the callbacks that Moodle has available: https://docs.moodle.org/dev/Callbacks.
Something that might work is the before_footer callback which you would define in your activity plugin's lib.php file.
Aha, of course! That will work perfectly thanks
That's also a really useful wiki page!