What approach are you using to obtain a session ID or are you putting the username/password credentials directly in to your XOG?
Which user does it use, one of your own created ones, or an internal one like process_admin? (please don't use this if so)
Have you marked the GEL script to perform synchronously or asynchronously? If asynchronously, can you change it?
Do you call the XOG logout service in your process, and is it in the same step/action or another step/action?
Do you have any gel scripts (anywhere) on the server that are attempting to 'flush caches' of the service?
What I'm trying to establish is whether there may be something that is invalidating your session in the BG before the operation could complete.