Is there a way to prevent apps from staying in Dock after quitting?

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?


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


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