Not sure if there is a better way but you could have a login event always running in the background, it would do nothing if the player is logged in, but when the player logs out it would pause the script executor, log back in, and then resume the script executor.
Consider looking at the code in the original post, shouldn't be hard to modify.