AttributeError: _as_dict when shutting down Home Assistant

Hello,

When shutting Home Assistant down, I have the following error in the log:

2022-06-15 09:40:11 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/storage.py", line 256, in _async_callback_final_write
    await self._async_handle_write_data()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/storage.py", line 276, in _async_handle_write_data
    await self.hass.async_add_executor_job(
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/storage.py", line 287, in _write_data
    json_util.save_json(
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/util/json.py", line 59, in save_json
    json_data = json.dumps(data, indent=4, cls=encoder)
  File "/usr/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/lib/python3.9/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.9/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 439, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/lib/python3.9/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.9/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/json.py", line 40, in default
    return super().default(o)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/json.py", line 20, in default
    return o.as_dict()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1126, in as_dict
    if not self._as_dict:
AttributeError: _as_dict

It does not occur if I shut HA down imediatly after starting it, it looks like it is only after some hours of activity.

I use Home Assistant Core now updated to 2022.6.6 on an Odroid N2+ under Raspbian Bullseye 22.05.
Last time I observed this error was when I updated Home Assistant 2022.6.5 to 2022.6.6.

Do I have an error on a JSON file in .storage? Using JQ all looks good and HA starts correctly, I suppose Home Assistant could not start if I had an mal-formed json file.

What could cause this kind of error?