What does this mean?
Where are you putting it // how are you setting that?
Usually systemd would be employed for this.
But if you are using Plasma you can also just use
System Settings > System > Autostart
And the “Add…” button allows you to add the script as “Add Logout Script” which should run on Log Out and may or may not be acceptable for your use-case.
(It is not clear whether you need this to run at the end of graphical session, or particularly right before powering down or …)