Why does quitting an application open the minimised window of a running application? In the windowing user interface, why does quitting an application open the minimised window of a running application?
This happens in Mavericks, and possibly earlier versions of the OS.
OSX is setup to have a window take focus, this usually requires a Window to show, this is being in the foreground. The application that this window belongs to  is the process that receives and interprets keystrokes (strictly key events) (after the system global ones are dealt with)

Thus when you quit an application the OS has to choose an Application to put in the foreground.

I can't find the overall description in one document so this is based on development experience. If someone could find the correct overview this would help.