Index: /trunk/gli/src/org/greenstone/gatherer/Gatherer.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/Gatherer.java	(revision 10386)
+++ /trunk/gli/src/org/greenstone/gatherer/Gatherer.java	(revision 10387)
@@ -468,17 +468,19 @@
      * @see org.greenstone.gatherer.gui.GUIManager
      */
-    public void exit() {
+    public void exit()
+    {
 	exit = true;
-	// If we have an open collection make note of it.
-	Configuration.setString("general.open_collection", true, null);
-	if(c_man.ready()) {
-	    ///ystem.err.println("Collection open.");
-	    if(c_man.saved()) {
-		///ystem.err.println("Collection has been recently saved, so I'll remember it for next time.");
-		Configuration.setString("general.open_collection", true, c_man.getCollectionFilePath());
-	    }
-	    c_man.closeCollection();
-	}
-	if(assoc_man != null) {
+
+	// If we have an open collection remember it for next time, then save it and close it
+	if (c_man.ready()) {
+	    Configuration.setString("general.open_collection", true, c_man.getCollectionFilePath());
+	    g_man.saveThenCloseCurrentCollection();
+	}
+	else {
+	    Configuration.setString("general.open_collection", true, null);
+	}
+
+	// Save the file associations
+	if (assoc_man != null) {
 	    assoc_man.save();
 	    assoc_man = null;
Index: /trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java	(revision 10386)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java	(revision 10387)
@@ -194,4 +194,12 @@
 	// Force all of the controls to be updated
 	valueChanged(null);
+    }
+
+
+    /** Called to inform this pane that it has just lost focus as an effect of the user clicking on another tab
+     */
+    public void loseFocus()
+    {
+	// Nothing to do
     }
 
Index: /trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 10386)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java	(revision 10387)
@@ -150,12 +150,10 @@
 	}
 	else if (esrc == menu_bar.file_close) {
-	    tab_pane.setSelectedComponent(gather_pane);  // Must be done before closing the collection
-	    Gatherer.c_man.saveCollection();
-	    Gatherer.c_man.closeCollection();
+	    saveThenCloseCurrentCollection();
 	}
 	else if (esrc == menu_bar.file_delete) {
 	    DeleteCollectionPrompt dcp = new DeleteCollectionPrompt();
 	    if (dcp.display()) {
-		Gatherer.c_man.closeCollection();
+		saveThenCloseCurrentCollection();
 	    }
 	    dcp.destroy();
@@ -176,4 +174,5 @@
 	}
 	else if (esrc == menu_bar.file_exit) {
+	    returnToInitialPane();
 	    exit();
 	}
@@ -188,7 +187,5 @@
 		// If there is already a collection open, save and close it
 		if (Gatherer.c_man.ready()) {
-		    tab_pane.setSelectedComponent(gather_pane);  // Must be done before closing the collection
-		    Gatherer.c_man.saveCollection();
-		    Gatherer.c_man.closeCollection();
+		    saveThenCloseCurrentCollection();
 		}
 
@@ -286,8 +283,9 @@
 
 
-    public void closeCurrentCollection() {
+    public void saveThenCloseCurrentCollection()
+    {
+	tab_pane.setSelectedComponent(gather_pane);
 	Gatherer.c_man.saveCollection();
 	Gatherer.c_man.closeCollection();
-	tab_pane.setSelectedComponent(gather_pane);
     }
 
@@ -690,6 +688,5 @@
 	    // If there is already a collection open, save and close it.
 	    if (Gatherer.c_man.ready()) {
-		Gatherer.c_man.saveCollection();
-		Gatherer.c_man.closeCollection();
+		saveThenCloseCurrentCollection();
 	    }
 
@@ -745,11 +742,16 @@
      * @param event A ChangeEvent containing information about the event that fired this call.
      */
-    public void stateChanged(ChangeEvent event) {
-	if(previous_pane != null) {
-	    if(previous_pane == create_pane) {
+    public void stateChanged(ChangeEvent event)
+    {
+	// Tell the previous pane that it has lost focus
+	if (previous_pane != null) {
+	    if (previous_pane == enrich_pane) {
+		enrich_pane.loseFocus();
+	    }
+	    else if (previous_pane == design_pane) {
+		design_pane.loseFocus();
+	    }
+	    else if (previous_pane == create_pane) {
 		create_pane.loseFocus();
-	    }
-	    else if(previous_pane == design_pane) {
-	       design_pane.loseFocus();
 	    }
 	}
Index: /trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java	(revision 10386)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java	(revision 10387)
@@ -718,5 +718,5 @@
 		// shut down the collection
 		System.err.println("shutting down teh collection");
-		Gatherer.g_man.closeCurrentCollection();
+		Gatherer.g_man.saveThenCloseCurrentCollection();
 	    }
 
