I've done what I believe is correct, which is exactly what you've done. The script executes in terminal but when it says it is running in ekos it does not do what it is supposed to do. I'm going to suggest that there is something I don't know about how Ekos executes shutdown scripts. I used to use scripts all of the time to move images from the default directories to the proper directories in between each capture and that worked perfectly.