diff --git a/ivette/src/frama-c/states.ts b/ivette/src/frama-c/states.ts
index d337a74dfd46f8f5927d92d66ec2dad9e5f46252..88301d9ac7ec584ec9a8a822456a325300d671ad 100644
--- a/ivette/src/frama-c/states.ts
+++ b/ivette/src/frama-c/states.ts
@@ -676,7 +676,8 @@ function reducer(s: Selection, action: SelectionActions): Selection {
   }
 }
 
-const GlobalSelection = new GlobalStates.State<Selection>({
+/** The initial selection is empty. */
+const emptySelection = {
   current: undefined,
   history: {
     prevSelections: [],
@@ -686,7 +687,10 @@ const GlobalSelection = new GlobalStates.State<Selection>({
     index: 0,
     allSelections: [],
   },
-});
+};
+
+const GlobalSelection = new GlobalStates.State<Selection>(emptySelection);
+Server.onShutdown(() => GlobalSelection.setValue(emptySelection));
 
 /**
    Current selection.