Index: trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs
===================================================================
--- trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs	(revision 9107)
+++ trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs	(revision 9219)
@@ -54,6 +54,5 @@
       Content.Refreshing += new EventHandler(Content_Refreshing);
       Content.Refreshed += new EventHandler(Content_Refreshed);
-      Content.HiveExperimentsChanged += new EventHandler(Content_HiveExperimentsChanged);
-
+      Content.HiveJobsChanged += new EventHandler(Content_HiveJobsChanged);
     }
 
@@ -61,5 +60,5 @@
       Content.Refreshing -= new EventHandler(Content_Refreshing);
       Content.Refreshed -= new EventHandler(Content_Refreshed);
-      Content.HiveExperimentsChanged -= new EventHandler(Content_HiveExperimentsChanged);
+      Content.HiveJobsChanged -= new EventHandler(Content_HiveJobsChanged);
       base.DeregisterContentEvents();
     }
@@ -123,10 +122,13 @@
 
     protected override void OnClosing(FormClosingEventArgs e) {
-      base.OnClosing(e);
-      if (Content != null && Content.Jobs != null) {
-        foreach (var exp in Content.Jobs.OfType<RefreshableJob>()) {
-          if (exp.RefreshAutomatically) {
-            exp.RefreshAutomatically = false; // stop result polling
-          }
+      if (Content.Jobs.Any(x => x.IsProgressing)) {
+        MessageBox.Show("The Hive Job Manager can only be closed after all down/uploads are finished. ", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
+        e.Cancel = true;
+      } else {
+        base.OnClosing(e);
+        if (Content != null && Content.Jobs != null) {
+          Content.Jobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);
+          Content.ClearHiveClient();
+          Content = null;
         }
       }
@@ -139,6 +141,8 @@
     }
 
-    private void Content_HiveExperimentsChanged(object sender, EventArgs e) {
-      Content.Jobs.ItemsRemoved += new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);
+    private void Content_HiveJobsChanged(object sender, EventArgs e) {
+      if (Content.Jobs != null) {
+        Content.Jobs.ItemsRemoved += new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);
+      }
     }
   }
Index: trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs	(revision 9107)
+++ trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs	(revision 9219)
@@ -71,4 +71,5 @@
       this.refreshButton = new System.Windows.Forms.Button();
       this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox();
+      this.UnloadButton = new System.Windows.Forms.Button();
       this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
       this.infoGroupBox = new System.Windows.Forms.GroupBox();
@@ -91,4 +92,5 @@
       // tabControl
       // 
+      this.tabControl.AllowDrop = true;
       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
             | System.Windows.Forms.AnchorStyles.Left)
@@ -377,8 +379,19 @@
       this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckChanged);
       // 
+      // UnloadButton
+      // 
+      this.UnloadButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Disconnect;
+      this.UnloadButton.Location = new System.Drawing.Point(30, 0);
+      this.UnloadButton.Name = "UnloadButton";
+      this.UnloadButton.Size = new System.Drawing.Size(24, 24);
+      this.UnloadButton.TabIndex = 27;
+      this.toolTip.SetToolTip(this.UnloadButton, "Unload Job");
+      this.UnloadButton.UseVisualStyleBackColor = true;
+      this.UnloadButton.Click += new System.EventHandler(this.UnloadButton_Click);
+      // 
       // refreshAutomaticallyCheckBox
       // 
       this.refreshAutomaticallyCheckBox.AutoSize = true;
-      this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(30, 5);
+      this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(70, 3);
       this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox";
       this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17);
@@ -471,6 +484,6 @@
       // RefreshableHiveJobView
       // 
-      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+      this.Controls.Add(this.UnloadButton);
       this.Controls.Add(this.searchButton);
       this.Controls.Add(this.isPrivilegedCheckBox);
@@ -505,5 +518,4 @@
     #endregion
 
-    private System.Windows.Forms.TabControl tabControl;
     private System.Windows.Forms.Button startButton;
     private System.Windows.Forms.Button stopButton;
@@ -539,4 +551,6 @@
     private MainForm.WindowsForms.ViewHost runCollectionViewHost;
     private System.Windows.Forms.Button searchButton;
+    private MainForm.WindowsForms.DragOverTabControl tabControl;
+    private System.Windows.Forms.Button UnloadButton;
 
   }
Index: trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
===================================================================
--- trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs	(revision 9107)
+++ trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs	(revision 9219)
@@ -100,4 +100,6 @@
         progressView = null;
       }
+      DeregisterHiveExperimentEvents();
+      DeregisterHiveTasksEvents();
       base.DeregisterContentEvents();
     }
@@ -111,10 +113,10 @@
     }
 
-    private void RegisterHiveJobEvents() {
+    private void RegisterHiveTasksEvents() {
       Content.HiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
       Content.HiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
       Content.HiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_CollectionReset);
     }
-    private void DeregisterHiveJobEvents() {
+    private void DeregisterHiveTasksEvents() {
       Content.HiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
       Content.HiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
@@ -131,9 +133,12 @@
           resourceNamesTextBox.Text = string.Empty;
           isPrivilegedCheckBox.Checked = false;
-          logView.Content = null;
           refreshAutomaticallyCheckBox.Checked = false;
           lock (runCollectionViewLocker) {
             runCollectionViewHost.Content = null;
           }
+          logView.Content = null;
+          jobsTreeView.Content = null;
+          hiveExperimentPermissionListView.Content = null;
+          stateLogViewHost.Content = null;
         } else {
           nameTextBox.Text = Content.Job.Name;
@@ -182,4 +187,6 @@
         this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
         this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started || Content.IsProgressing;
+
+        this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing;
       }
       SetEnabledStateOfExecutableButtons();
@@ -286,5 +293,5 @@
         if (Content != null && Content.HiveTasks != null) {
           jobsTreeView.Content = Content.HiveTasks;
-          RegisterHiveJobEvents();
+          RegisterHiveTasksEvents();
         } else {
           jobsTreeView.Content = null;
@@ -435,10 +442,10 @@
 
     private void nameTextBox_Validated(object sender, EventArgs e) {
-      if (!SuppressEvents && Content.Job.Name != nameTextBox.Text)
+      if (!SuppressEvents && Content.Job != null && Content.Job.Name != nameTextBox.Text)
         Content.Job.Name = nameTextBox.Text;
     }
 
     private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
-      if (!SuppressEvents && Content.Job.ResourceNames != resourceNamesTextBox.Text)
+      if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
         Content.Job.ResourceNames = resourceNamesTextBox.Text;
     }
@@ -564,4 +571,14 @@
       }
     }
+
+    private void UnloadButton_Click(object sender, EventArgs e) {
+      Content.Unload();
+      runCollectionViewHost.Content = null;
+      stateLogViewHost.Content = null;
+      hiveExperimentPermissionListView.Content = null;
+      jobsTreeView.Content = null;
+
+      SetEnabledStateOfControls();
+    }
   }
 }
