When I’m done with the work, I enter “quitall” with Alfred and quit all the apps in the Dock. I found out that I need more control to decide which apps to keep active.

I’ve been using Alfred built-in Quit All to quit all the applications whenever I’m done with my work. It’s a great way to end the day so you can see a clean working space.

However, there are some apps that I want to keep active in the Dock such as Timemator for time tracking and Drafts for note-taking. Unfortunately, Alfred doesn’t have a built-in option to exclude apps from this command.

Which brings me to Keyboard Maestro.

Keyboard Maestro offers more flexibility when it comes to building a macro that caters to your needs. All you need to do is to add the apps you want to exclude from the preferences and the app will take care of the rest.

The next thing you want to do is to create a search command in Alfred that runs /usr/bin/osascript (AppleScript). You can paste the script below to tell Keyboard Maestro Engine to execute the

-- The passed query is the UUID of the macro
tell application "Keyboard Maestro Engine"
  do script "5F2B4E32-239D-4B46-BA07-2F0F103CE1EA"
end tell

You can get the UUID of a macro by right-clicking and selecting Copy as UUID from the contextual menu. For example, 5F2B4E32-239D-4B46-BA07-2F0F103CE1EA is the UUID for the Quit All macro in my library.