Kodi sometimes freezes after resuming from sleep

Hi,
I use Kodi under EndeavorOS with an USB-CEC adapter.
When I press the power button on the TV remote, I have set up the adapter so that the HTPC also goes to sleep. It works well.
In order to wake up everything, I have to press a key on the keyboard (to wake up the HTPC) and the power button on the TV remote (to wake up the TV).
Then, sometimes, the instance of Kodi which used to be active is completely frozen. Do you have any idea why this can happen? I have seen nothing in kodi.log nor using journalctl. A workaround would be to force Kodi to exit before going to sleep (or to restart at wakeup). Any idea?
Thanks