Change "focus switch" behaviour in OS X Yosemite So, this is a small and very annoying gripe I have with Yosemite:
Whenever I close a window, say a Chrome window, it automatically switches focus to the next open Chrome window, regardless of the last active window I was in before closing the Chrome window. So if for example I'm closing a window in the background, I completely lose focus of where I was before.

Any way to rectify this annoyance?
macOS is an application-centric model (by most recently used), whilst Windows uses a window-centric model (by z-order).

Read more: https://www.isotoma.com/blog/2010/05/10/solving-the-real-alt-tab-problem/

You can use a number of third-party apps to make macOS use a window-centric model, see the answers to this question for some examples.