@webodan I found my own solution in this github post. All it took was adapting his SwitchToKodi script to kill Xorg after emulationstation was dead instead of having a user switch.
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first