Problem: Stopping multiple logins in windows application

I m making a windows based client server application. I want to stop same user from signing in the application simultaneously from different machines on the network. For implementing this I have kept a flag in DB which is set when user is logged in and cleared on log off. If this flag is set then it stops user from entering into the system if he is already signed in.

Now the issue is that if the application crashes for some reason (e.g power breakdown etc) then the flag remains set as it is not the normal shutdown of the application and the user is unabled to logged in. Is there any other way I can address this issue.