A shortcut to quit the current app

Is it possible to create a shortcut (that is, using the Shortcuts app) to quit the current app? I can see how to quit a specific app or all the currently opened apps, but I can’t see how to quit just the app you are currently using. I plan to use this shortcut using Siri, something like: “Siri, open Keynote”, “Siri, quit Keynote”.

1 Like

I’m going to make a radical suggestion. Don’t be concerned about closing apps, especially those that do nothing in the background like Keynote. Use ⌘W to close a document if you are done with it, but there is little reason to exit the application itself.

6 Likes

I have about 50 applications running on my M1 MacBook Pro. It’s never occurred to me that I need to close any applications for better performance. I don’t even realize that I need to close any.

Well, I prefer to quit them because an opened app is strongly associated with unfinished work for me. This is a question not of performance but of my personal convenience (and yes, maybe some kind of neurotism).

I can understand that, I used to be the same way, but I don’t worry about it anymore. Why not just hit command-Q when you are done using an app. No need for a shortcut.

2 Likes

By the same token, do worry about quitting apps that are heavy on resources. Lightroom, DxO PhotoLab, Apple Photos, Safari with a couple dozen tabs, various social apps, Mimestream, and whatever is running in the background… then my 16 GB M1 system is showing signs of strain. If I’m bouncing between those first three, I will temporarily quit Safari and Mimestream. If I’m not really bouncing, I will close Photos when not immediately needed as it launches fast. And so on.

But this does also illustrate that even a 16 GB M1 can cope with quite a lot!

1 Like

I don’t know if Lightroom’s app is the problem, but all the little helper apps it likes to run. For me, whenever my Mac isn’t acting normal, it’s not the apps I am not using, but the active tasks in Activity Monitor acting badly. Adobe is really bad in this area.

2 Likes

Here’s one way to do it with Shortcuts. This AppleScript gets the name of the current app.

tell application "System Events"
	return name of first process whose frontmost is true
end tell

You can pass its result to a Quit App action.

3 Likes

Many thanks, Evan. As I discovered, it is also possible to use “Run Applescript” to press Command-Q, and that’s it.

tell application "System Events"
    keystroke "q" using command down
end tell

I guess I don’t understand what you are trying to do. Isn’t it faster and easier to just hit command-Q than to run a script to press Command-Q for you?

4 Likes

Exactly. From time to time apps can misbehave - memory leaks, for example, consuming resources. And if you restart your Mac and the checkbox “reopen windows when logging back in” is enabled, all of the previously-open apps will re-launch, websites re-load, etc. Many of these might require user interaction (such as a login) or might cause a delay, use bandwiddth, etc.

Granted, macOS handles this gracefully. It’s OK to leave well-behaved apps running in the background. But I prefer to avoid leaving apps running for long periods of time - overnight, for example.