Change Focus Mode by App Quit Trigger?

Hi Team

I couldn't find this when I was searching the forum, so here it is.

I'd like to be able to tell my Mac to exit Work Focus (the MacOS Focus system) when exiting an app. Is there an action to help with this in KM?

Also (bonus cheeky extra question), re the trigger itself, the app quit: is there any way of differentiating between the app quitting itself or me (the user) actively quitting the app? Ideally, I'd want this only to be triggered when I, the user, takes action to quit vs just random errors in the app.

Many thanks as always for your help!!

I believe Shortcuts can work directly with Focus, and KM can run shell scripts and AppleScripts – so this should be possible

I'm still using Mojave, so I can't test, but here's food for thought:

Not really – Keyboard Maestro can notice when an app quits, but it can't differentiate whether or not it crashed.

You could hijack Cmd-Q in your apps, but that would not include apps quit via menu item or other means.