I’m sorry to revive this old thread, but it’s what comes closest to my problem.
I have this almost working on Raspbian Stretch with Kodi 17.6 Krypton. I haven’t tried on my OSMC image yet.
I have added dtoverlay=gpio-shutdown,gpio_pin=3 to /boot/config.txt (and /boot/overlays/gpio-shutdown.dtbo is of course present).
Nothing happens when I press the button, if Kodi is running, but when I exit Kodi and use the Raspbian desktop, then pressing the button works fine.
What needs to be configured to make it work inside Kodi?
/Mogens