Thanks blokhead!!
KDE's autostart thing did kill the script on logout but there was no reason to keep it running after the last action. So thanks again.
I think maybe next time I've got some free time I'll put the actions in a config file using YAML::Tiny or something. Then I can put the actions in a readable file in my home folder and not have to worry about being root and all that to alter the actions. However, I don't think I should put code in the config, so I'll have to figure that out. Time to start reading...
KennV