Another suggestion. It would probably be wise to add "--signal=9" to the loginctl call. This will help prevent any badly-behaved guest processes from hanging around after the guest session ends. I wouldn't recommend going back to the old while loop that uses killall and sleep. It looks like that loop will prevent the guest login from *ever* logging out if the guest manages to create a zombie process. Thinking back on it, I believe that I encountered that behavior in the past.
Another suggestion. It would probably be wise to add "--signal=9" to the loginctl call. This will help prevent any badly-behaved guest processes from hanging around after the guest session ends. I wouldn't recommend going back to the old while loop that uses killall and sleep. It looks like that loop will prevent the guest login from *ever* logging out if the guest manages to create a zombie process. Thinking back on it, I believe that I encountered that behavior in the past.
A revised patch file is attached.