Ctrl+Q closes second windows with loss of unsaved changes
Describe the bug
The key shortcut Ctrl+Q, which I use to quit all windows of an app, only closes the frontmost window in Code. If used with multiple windows with unsaved documents, this behavior loses those documents without warning.
Since Ctrl+Q is used to quit (with state restored when you reopen), it doesn't warn about the unsaved document. However, since it only works on one window at a time, this window's content is the only one that's saved. When I close a second window, the same behavior repeats but any unsaved content is not cached for restore.
To Reproduce
Steps to reproduce the behavior:
- Open two new documents in separate windows and type in them to create unsaved changes
- Quit one window using Ctrl+Q
- Quit the other window using Ctrl+Q
- Open Code, only the first window to close will be restored
Expected behavior
All unsaved content will either be cached for restore or disappear with a warning to the user.
Screenshots or screen recordings
State before quitting the app:

I quit the left window first, then the right. Then I open Code:

Note how some application state (open documents) is restored from the first window, while other (window size and position) is restored from the second window.
Platform Information

- [ ] I'm using the latest version from git that I've manually compiled
- [X] I'm using the latest released stable version
This also happens when you log out!
I would consider this a critical bug. A program that loses data is not usable.
I am not sure that much can be done about logging out, at least not in Code code. The system just kills the applications without allowing them to shutdown gracefully. I believe an issue has been raised about this elsewhere.
I agree <Ctrl>Q should not have this effect and I am surprised it does.
I see now it is only multiple windows that are affected - it is true that at the moment Code only has the ability to save the state of one window and it is this window that is restored. I guess even so that in this case any document that was open in other windows should be restored into the first window and in any case all documents should be saved. I guess the workaround is to give all new documents a name and have "autosave" switched on (which is the default I think).
A similar issue affects Files, although in that case you do not lose data.
This thing about window position should really be a separate issue.
Maybe the "autosave edited files" should be ON by default? At the moment it is off.
There is some overlap with issue #1499
The linked PR address the loss of unsaved data when a second window is closed. At the moment it is not intended that <Ctrl>Q should close all open windows as it becomes more complicated to ensure there is no loss of data and all open documents will be restored.
Update: The linked PR now implements <Ctrl>Q to close all windows, as advised by @danirabbit. To close the focused window the shortcut <Alt>F4 can be used. Windows are only closed if the docs it is showing are saved to disk or the user specifies closing without saving.