# Prevent OS X from changing Spaces after quitting an App?

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.

-
Don't quit your apps :) –  jtbandes Aug 3 '11 at 4:01

As far as I know, there's no way to do exactly what you want, but you can come pretty close. It's true that if you uncheck the "When switching..." checkbox, you don't go to the app when you click on the icon in the dock, but you do go to the app when you double click it (or just generally click it a second time when the application is active but nothing is visible).

I've been using it this way for years - I'd almost forgotten there was any other behavior.

-
Thank you! This was exactly what I wanted: the "When switching..." unchecked behavior with Dock behavior left in-tact. The only other undesirable effect is that built-in Cmd-Tab doesn't switch either. For that I just replaced the built-in tab-switcher with Witch. –  Pewpewarrows Mar 21 '12 at 17:37
I thought this happens because the system is switching back to the previous app, but that's not it. Something is causing explicit switching to apps in different desktops (and subsequently switching the space). After disabling the "When switching..." option, in addition to not switching spaces, it also no longer switches to the "wrong" app. Instead it simply returns to the app you were using right before the app being closed. I wish there was a way to just disable that bug. I'd say, switching spaces when switching apps, in itself, is fine. –  Krinkle Jun 15 '14 at 13:59

You can force apps to open in certain spaces from System Preferences, which would solve the problem of Chrome opening in a space it shouldn't.

The drawback is that I don't think it will stop the transition from one space to another, and then back again.

-

This works on 10.6.8. Just used it myself. Enjoy!

For Leopard 10.5.0–10.5.2, the solution was to access a hidden preference for Spaces by issuing the following command in a Terminal or xterm (X11) window:

defaults write com.apple.dock workspaces-auto-swoosh -bool NO

then restarting the Dock using the following command:

killall Dock

Source

-
As noted in the article, this has the same effect as the System Preference for: When switching to an application, switch to a space with open windows for the application, which is not what I want. I'd still like to be able to use the Dock to switch to currently-opened windows of the application. –  Pewpewarrows Jan 20 '12 at 19:52