You might wanna check out @mcobit’s post about using RetroPie with OSMC. His retropie.sh script will close Kodi and start EmulationStation. Once you close EmulationStation, Kodi restarts. Sounds like what you are trying to accomplish.
Also a link to his github page: