automation.turn_off will do that, but has the side- (or primary, really) effect of disabling the trigger. If you instead put the action into a script, then you can use script.turn_off.
This seems to generally work - and I haven’t found any other way of terminating a running automation other than a restart of HA. I see that people have suggested writing automations to cancel an automation - but that sort of defeats the purpose - needing to write an automation every time you want to cancel something that is already running :-
I think though that you need to make a significant change to the automation and re-save it to cancel it. For example, I have an automation with a repeat loop 15x in it. Just changing the description allows me to re-save it - but will not stop it from continuing to run. Changing the loop counter to a number lower than it is currently at (for example, my automation has run 7 of its 15 iterations, so I set the repeat loop counter to 5, and then save it. Now set it back to 15 and save it again - and the automation will have ended.