Take the 2-minute tour ×

There are two common ways to exit a program in Windows:

  1. Click on File in the menu bar and select Exit from the resulting menu
  2. Click on the X button in the upper right corner

Assume, for the sake of this question, that you're dealing with the last window the program has open. Assume also that you're not dealing with a program that sneakily stays open as a background process even when it doesn't have active windows.

Are these methods equivalent to each other? If not, what's the difference? For example, does one clean up resources more fully than the other?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Ignacio's answer is good, but I though I'd add a less techincal version.

File -> Exit is provided by the software (and some software doesn't even have a file menu or exit option), and the software will handle it however it wants.

The X is attached to any standard window by the OS (which also provides the standard window itself). Clicking it effectively sends an external message to the window asking it to close. It's up to the software to check for this message, and respond correctly.

You would expect most software to use the same internal procedures for both types of requests, but this is not guaranteed, as said, because it's entirely up to the software developers to configure them.

Also, neither method is guaranteed to close the program - think about doing either in Excel with an edited file sat open, it will ask if you wish to save, but also gives you the option to cancel the request entirely.

share|improve this answer

One posts the command message assigned to the menu item to the window message queue, the other posts a WM_CLOSE message to the window message queue. How the application reacts to each is determined by how the window loop processes the given message.

share|improve this answer

Your Answer


