private void closeThisWindow() {
		final String[] options = new String[]{"Save", "Discard", "Cancel"};
		int ret = JOptionPane.showOptionDialog(theFrame,
				"You have unsaved changes", "Warning", 0, 0, null,
				options, options[0]);
		switch(ret) {
		case -1: case 2: // -1 is cancel, +2 is Cancel
			return;
		case 0:
			try {
				doSave(fileName);
			} catch (IOException ex) {
				JOptionPane.showMessageDialog(theFrame,
						"That didn't work: " + ex);
				return;
			}
			// FALLTHROUGH
		default:
			// nothing to do
		}
		theFrame.setVisible(false);
		theFrame.dispose();
		synchronized(windows) {
			windows.remove(this);
			if (windows.size() == 0) {
				if (isStandalone) {
					System.exit(0);
				} else {
					// imbedded - nothing to do.
				}
			}
		}
	}