Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/collection/ServiceCluster.java	(revision 9824)
@@ -34,4 +34,5 @@
 import java.io.File;
 import java.util.HashMap;
+import java.util.Iterator;
 
 /* ServiceCluster - a groups of services that are related in some way
@@ -91,4 +92,11 @@
     }
 
+    public void cleanUp() {
+	Iterator i = this.service_map.values().iterator();
+	while (i.hasNext()) {
+	    ServiceRack s = (ServiceRack)i.next();
+	    s.cleanUp();
+	}
+    }
     public void setClusterName(String name) {
 	this.cluster_name = name;	
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java	(revision 9824)
@@ -48,4 +48,5 @@
 	converter_ = new XMLConverter();
     }
+    public void cleanUp() {}
 
     public void setLocalSiteName(String name) {
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java	(revision 9824)
@@ -98,8 +98,14 @@
 	this.converter = new XMLConverter();
 	this.doc = this.converter.newDOM();
-	
-	
-    }
-
+    }
+
+    public void cleanUp() {
+	if (this.module_map != null) {
+	    Iterator i = this.module_map.values().iterator();
+	    while (i.hasNext()) {
+		((ModuleInterface)i.next()).cleanUp();
+	    }
+	}
+    }
     /** site_home must be set before configure called */
     public void setSiteHome(String home) {
@@ -807,6 +813,6 @@
 
 	    System.out.println("MessageRouter: deactivating "+name);
-	    this.module_map.remove(name);
-
+	    ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
+	    m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows
 	    // also remove the xml bit from description list
 	    if (type.equals(GSXML.COLLECTION_ELEM)) {
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/ModuleInterface.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/ModuleInterface.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/ModuleInterface.java	(revision 9824)
@@ -52,4 +52,11 @@
    */
     abstract public Element process(Element xml_in);
+
+    /** 
+     * Do any clean up necessary for deactivating the module, eg
+     * close any open file handles (gdbm in particular) or windows
+     * holds locks on them.
+     */
+    abstract public void cleanUp();
 }    
                                                                            
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java	(revision 9824)
@@ -50,4 +50,5 @@
     }
     
+    public void cleanUp() {}
     public void setParams(GSParams params) {
 	this.params = params;
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java	(revision 9824)
@@ -67,5 +67,8 @@
     }
 
-
+    public void cleanUp() {
+	super.cleanUp();
+	this.gdbm_src.closeDatabase();
+    }
     /** configure this service */
     public boolean configure(Element info, Element extra_info)
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS3DocumentRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS3DocumentRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS3DocumentRetrieve.java	(revision 9824)
@@ -63,5 +63,9 @@
 	// set up a macro resolver
     }
-
+    
+    public void cleanUp() {
+	super.cleanUp();
+	this.database.closeConnection();
+    }
 
     /** configure this service */
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGPPSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGPPSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGPPSearch.java	(revision 9824)
@@ -112,4 +112,9 @@
     {
 	this.mgpp_src = new MGPPWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mgpp_src.unloadIndexData();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGSearch.java	(revision 9824)
@@ -77,4 +77,8 @@
     }
 
+    public void cleanUp() {
+	super.cleanUp();
+	this.mg_src.unloadIndexData();
+    }
     public boolean configure(Element info, Element extra_info)
     {
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Browse.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Browse.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Browse.java	(revision 9824)
@@ -56,4 +56,9 @@
     }
 
+    public void cleanUp() {
+	super.cleanUp();
+	this.gdbm_src.closeDatabase();
+    }
+
     public boolean configure(Element info, Element extra_info)
     {
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java	(revision 9824)
@@ -48,4 +48,9 @@
     public GS2MGPPRetrieve() {
 	this.mgpp_src = new MGPPWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mgpp_src.unloadIndexData();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java	(revision 9824)
@@ -42,4 +42,9 @@
     {
 	this.gdbm_src = new GDBMWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.gdbm_src.closeDatabase();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java	(revision 9824)
@@ -45,4 +45,9 @@
     public GS2MGRetrieve() {
 	this.mg_src = new MGWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mg_src.unloadIndexData();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java	(revision 9824)
@@ -42,4 +42,8 @@
     {
 	this.gdbm_src = new GDBMWrapper();
+    }
+    public void cleanUp() {
+	super.cleanUp();
+	this.gdbm_src.closeDatabase();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Browse.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Browse.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3Browse.java	(revision 9824)
@@ -52,4 +52,9 @@
     }
 
+    public void cleanUp() {
+	super.cleanUp();
+	this.database.closeConnection();
+    }
+    
     public boolean configure(Element info, Element extra_info)
     {
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPRetrieve.java	(revision 9824)
@@ -46,4 +46,9 @@
     public GS3MGPPRetrieve() {
 	this.mgpp_src = new MGPPWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mgpp_src.unloadIndexData();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGPPSearch.java	(revision 9824)
@@ -50,4 +50,9 @@
     {
 	this.database = new SQLQuery();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.database.closeConnection();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGRetrieve.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGRetrieve.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGRetrieve.java	(revision 9824)
@@ -43,6 +43,12 @@
     private String mg_textdir = null;
     private String default_index = null;
+    
     public GS3MGRetrieve() {
 	this.mg_src = new MGWrapper();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mg_src.unloadIndexData();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/GS3MGSearch.java	(revision 9824)
@@ -50,4 +50,9 @@
     {
 	this.database = new SQLQuery();
+    }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.database.closeConnection();
     }
 
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java	(revision 9824)
@@ -100,4 +100,7 @@
 
   }
+  
+  public void cleanUp() {}
+  
   /** The all-args constructor */
   public ModuleWrapper(String in,String out, ModuleInterface inner){
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java	(revision 9824)
@@ -56,4 +56,10 @@
 	this.mgpp_src.setCase(true);
     }
+
+    public void cleanUp() {
+	super.cleanUp();
+	this.mgpp_src.unloadIndexData();
+    }
+
     /** configure the service module
      *
Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java	(revision 9823)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java	(revision 9824)
@@ -95,4 +95,6 @@
 	setClusterName(coll_name);
     }
+
+    public void cleanUp() {}
     
     /** sets the site home */
