Hello Mick N.,
Thank you for the question. If you are developing a Joomla plugin, then you may know better than us how to use the code as we are not developers ourselves. I did look around a little bit and got the opinions of a few of our systems people here. They believe that there is probably a way for you to have a hook in your plugin that can write to the FOOTER. Since that would be the last section of possible text before the body closes. There's a module in the module manager called Module Footer. This should hopefully get you pointed in the right direction. I found it by looking at the Joomla Developers documentation.
Please let us know if you have any further questions.
Regards,
Arnel C.