Updated to use a timer to quit after a lock event. Cancel timer on unlock