src/vs/workbench/services/workspaces/electron-sandbox/workspaceEditingService.ts/NativeWorkspaceEditingService/saveUntitledBeforeShutdown
class NativeWorkspaceEditingService:	private async saveUntitledBeforeShutdown(reason: ShutdownReason): Promise<boolean> {
		if (reason !== ShutdownReason.LOAD && reason !== ShutdownReason.CLOSE) {
			return false; // only interested when window is closing or loading
		}

		const workspaceIdentifier = this.getCurrentWorkspaceIdentifier();
		if (!workspaceIdentifier || !isUntitledWorkspace(workspaceIdentifier.configPath, this.environmentService)) {
			return false; // only care about untitled workspaces to ask for saving
		}

		const windowCount = await this.nativeHostService.getWindowCount();
		if (reason === ShutdownReason.CLOSE && !isMacintosh && windowCount === 1) {
			return false; // Windows/Linux: quits when last window is closed, so do not ask then
		}

		enum ConfirmResult {
			SAVE,
			DONT_SAVE,
			CANCEL
		}

		const buttons = [
			{ label: mnemonicButtonLabel(localize('save', "Save")), result: ConfirmResult.SAVE },
			{ label: mnemonicButtonLabel(localize('doNotSave', "Don't Save")), result: ConfirmResult.DONT_SAVE },
			{ label: localize('cancel', "Cancel"), result: ConfirmResult.CANCEL }
		];
		const message = localize('saveWorkspaceMessage', "Do you want to save your workspace configuration as a file?");
		const detail = localize('saveWorkspaceDetail', "Save your workspace if you plan to open it again.");
		const { choice } = await this.dialogService.show(Severity.Warning, message, buttons.map(button => button.label), { detail, cancelId: 2 });

		switch (buttons[choice].result) {

			// Cancel: veto unload
			case ConfirmResult.CANCEL:
				return true;

			// Don't Save: delete workspace
			case ConfirmResult.DONT_SAVE:
				await this.workspacesService.deleteUntitledWorkspace(workspaceIdentifier);
				return false;

			// Save: save workspace, but do not veto unload if path provided
			case ConfirmResult.SAVE: {
				const newWorkspacePath = await this.pickNewWorkspacePath();
				if (!newWorkspacePath || !hasWorkspaceFileExtension(newWorkspacePath)) {
					return true; // keep veto if no target was provided
				}

				try {
					await this.saveWorkspaceAs(workspaceIdentifier, newWorkspacePath);

					// Make sure to add the new workspace to the history to find it again
					const newWorkspaceIdentifier = await this.workspacesService.getWorkspaceIdentifier(newWorkspacePath);
					await this.workspacesService.addRecentlyOpened([{
						label: this.labelService.getWorkspaceLabel(newWorkspaceIdentifier, { verbose: true }),
						workspace: newWorkspaceIdentifier,
						remoteAuthority: this.environmentService.remoteAuthority // remember whether this was a remote window
					}]);

					// Delete the untitled one
					await this.workspacesService.deleteUntitledWorkspace(workspaceIdentifier);
				} catch (error) {
					// ignore
				}

				return false;
			}
		}
	}