The CMD+Q shortcut is supposed to quit the current app
CMD+W is the shortcut you want to use to close the current window. (like the Settings window you are mentioning)
This works as expected in Docker for Mac.
However, we may consider adding a “Are you sure you want to quit Docker for Mac” popup to avoid the experience you are describing.