Reset locked variable when releasing the lock. #976