The answer that you are looking for is Microsoft Word's FileCloseOrExist command.
It does exactly what you want. If you have 2 documents open and you execute the FileCloseOrExit command, then only the active document closes. When you execute the FileCloseOrExit command a second time now when only 1 document is open, it will close the last document and then terminate Microsoft Word.
Whenever I install Microsoft Word on a new computer, one of the first things I do is change the hotkey, Control+W from FileClose to FileCloseOrExit. To be honest, I don't know why they even have FileClose. FileCloseOrExist is the same thing but adds terminating Microsoft Word with the last document. It's much better.
To change the Control+W hotkey to this command, you need to:
- Select File which is the first menu selection located at the top left.
- Select Options that is the last selection in the File menu.
- The Word Options window appears with a list on the left. Select Customize Ribbon that is located 4th from the bottom.
- 2 lists will appear in the window. Click Customize that is at the bottom of the left list. It's immediately right of the text that says, "Keyboard shortcuts:".
- Under Categories, scroll all the way to the bottom. Click "All Commands" and the Command list to the right will show all possible commands. Scroll down the alphabetized list to FileCloseOrExit.
- Input Control+W as the hotkey. Click the Assign button at the bottom left.
There you have it. Now, every time you press Control+W in Microsoft Word, the program will automatically exit the program when you close the last document instead of leaving an ugly blank Word program.