 class HistoryHelper {
 
     @objc static func saveCurrentAtTerminate(note: NSNotification) {
-        SettingsDB.shared.storeHistory(history: HistoryModel.shared.currentHistory())
+        HistoryModel.shared.changeReference(reference: nil) // Saves _current if necessary
         SettingsDB.shared.cleanUpHistory()
     }
 }

        SettingsDB.shared.clearHistory()
    }
    
    private mutating func add(reference: Reference) {
        let newItem = History(reference: reference)
        if newItem.datetime - self._current.datetime > HistoryModel.SAVE_ON_DELAY
            && self._current != self._history.last {
            self._history.append(self._current)
            SettingsDB.shared.storeHistory(history: self._current)
        }
        self._current = newItem
    }
    
    func current() -> Reference {

        self.add(reference: ref)
    }
    
    mutating func changeReference(reference: Reference?) {
        self.add(reference: reference)
    }
    
