Lock access to WebScreen if someone else is on it


Does someone know how to lock the access to an Edit WebScreen if another user already is using it? Actually i'm setting a flag, so when someone tries to go there i show a warning. But the only way i'm being able to unset this flag is if the user actually click in one button, anyway else it keeps showing the warning until someone go there and use the button.

Sorry my bad english, it isn't my mother tongue.

How may i use it to recognize when a user leave the WebScreen? (Even if the user closes the browser)