Here are the steps you should take. First:
/scoreboard objectives add JustLeft stat.leaveGame
Creates a score for keeping track of logging out. Then link the next command to a clock:
/scoreboard players set @a[score_JustLeft_min=1] (your objective) 0
Which will reset whatever the objective is. Finally:
/scoreboard players set @a[score_(your objective)_min=1] JustLeft 0
Which resets the "JustLeft" score. You can find all the same steps in the following post:
How to detect if a player logs out of the game in Minecraft?
I don't know which version you're using, so if the above doesn't work it might be due to that. If you specify the version I can help more.