Merging into 1.2.0 branch for bug 344336

git-svn-id: http://dev.eclipse.org/svnroot/technology/org.eclipse.stem/branches/STEM_1_2_0@1695 92a21009-5b66-0410-b83a-dc787c41c6e9
diff --git a/org.eclipse.stem.ui.headless/src/org/eclipse/stem/ui/headless/HeadlessSimulationRunner.java b/org.eclipse.stem.ui.headless/src/org/eclipse/stem/ui/headless/HeadlessSimulationRunner.java
index 366fd6f..e51034c 100644
--- a/org.eclipse.stem.ui.headless/src/org/eclipse/stem/ui/headless/HeadlessSimulationRunner.java
+++ b/org.eclipse.stem.ui.headless/src/org/eclipse/stem/ui/headless/HeadlessSimulationRunner.java
@@ -229,6 +229,7 @@
 		for (ISimulation sim : MANAGER.getActiveSimulations()) {
 			try {
 				sim.join();
+				sim.stop();
 			} catch (InterruptedException e) {
 				System.err.println("Simulation interrupted.");
 			}
diff --git a/org.eclipse.stem.util.loggers/src/org/eclipse/stem/util/loggers/views/CustomCSVLogger.java b/org.eclipse.stem.util.loggers/src/org/eclipse/stem/util/loggers/views/CustomCSVLogger.java
index 379e4a0..13613dd 100644
--- a/org.eclipse.stem.util.loggers/src/org/eclipse/stem/util/loggers/views/CustomCSVLogger.java
+++ b/org.eclipse.stem.util.loggers/src/org/eclipse/stem/util/loggers/views/CustomCSVLogger.java
@@ -157,9 +157,9 @@
 				logWriter.logData(this.simulation, this.diseaseModel, this.nodeLevels, timeProvider, false);
 			}
 			//} // if
-		} else 
-		// Is the Simulation stopping (i.e. being deleted?)
-		if (event.getSimulationState() == SimulationState.STOPPED) {
+		}  else if (event.getSimulationState() == SimulationState.PAUSED) {
+			flushLoggerData();
+		} else if (event.getSimulationState() == SimulationState.STOPPED) {
 			close();
 		} // if