101

Certain OSX apps seem to have a tendency to stick around in the Dock, even though there's no user-facing setting to prevent this behavior. Is there a defaults command that prevents apps from enabling "Keep in Dock?"

I know about defaults write com.apple.dock persistent-apps -array (intentionally empty), but this has to be run manually, and repeatedly. Any ideas?

Kevin Suttle
  • 1,566
  • How do You quit an app? If it was not kept in Dock before opening, hitting ⌘CMD + Q to close an app should remove icon form the Dock. – Mateusz Szlosek Jan 20 '16 at 18:58
  • 4
    To date (27 March, 2019) each of the answers here fails the actually does something test. I know this comment sounds negative, because it is, but at the same time maybe it can save somebody some disappointment. – Michael Wolf Mar 27 '19 at 15:42
  • @MichaelWolf The highest voted answer (by @Shrihari) does what the OP is looking for. The question assumes that no UI exists to prevent the keep-in-dock behavior, thus they ask for a defaults command. That UI does exist tho and does exactly what is desired here. – Constablebrew May 22 '19 at 06:11
  • @Constablebrew It doesn't. If you move an open app's position in the dock and then quit the app, its icon stays there, even if you have unchecked the option mentioned. – Michael Wolf May 22 '19 at 16:46
  • 3
    @MichaelWolf Dragging an icon is explicitly setting its position, thus saving it to the dock (and over-riding any preferences). Setting the preference to not show recent apps in dock and also not dragging an app icon does just what OP is asking for - the app icon goes away when the app is closed. – Constablebrew Jul 12 '19 at 00:25

4 Answers4

197

I think I understand your problem.. Open System Preferences, Click on dock, uncheck "Show recent applications in dock". This should probably solve your problem.

Srihari
  • 1,987
8

Even after the below configuration, some applications might still run in background (. symbol in dock) & appears in dock

Open System Preferences, Click on dock, uncheck "Show recent applications in dock"

For instance, terminal/iterm2 they do not disappear from dock when closing from window.

For disappearing the application from dock, Command key, ⌘ + Q

so basically, some applications like in launchpad close immediately from dock as soon as they are closed from window but, if they don't disappear from dock then ⌘ + Q will be the solution

2

It seems like in Mojave (10.14) the following will do the trick:

defaults write com.apple.dock show-recents -bool no
defaults write com.apple.dock recent-apps -array # intentionally empty
fresskoma
  • 121
1

Either the app needs to be quit with command+q, or you need to just drag the icon out of the dock, and it'll be gone.