After quitting an application, the previous app that I was interacting with is automatically selected. If I was working in Terminal, switched to Chrome, and then decided to quit Chrome, Terminal becomes the active context. Unfortunately, if Terminal happened to be in a different space at the time, OS X swaps to that space for me.
This effect is pretty jarring every time it happens, and it really gets in the way if, say, Chrome was merely restarting. In that case not only do I get sent to a completely different space, but Chrome then opens itself up in that space where I don't want it.
The only question I could find similar to my problem was: How can I stop spaces from switching automatically?
It suggests to go under System Preferences -> (Spaces / Mission Control), and uncheck
When switching to an application, switch to a space with open windows for the application.
While this technically solves my problem, I'm now unable to swap to an open application by simply clicking its icon in the Dock. I can live with this if I have to, but I'd rather have a real solution that doesn't require me to sacrifice quick app-switching.
Ideally I'd like it to switch context to the most-recently used application that's currently open in the existing space. If none exist, default to the Finder.