Put lock in try-finally