diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index 8d3213a4805..66eb06f4d27 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -421,8 +421,8 @@ class Recorder(threading.Thread): def _close_run(self): """Save end time for current run.""" - self._run.end = dt_util.utcnow() with session_scope() as session: + self._run.end = dt_util.utcnow() self._commit(session, self._run) self._run = None