There are two general hints you should keep in mind, when you are locking objects:
1.) put locking-orders in a try- or finally-block
The try-/finally-block makes sure, that the locked object will be released again in any case - even if an error appears.
Otherwise the object will be locked on the server for the whole runtime of the session, which locked the object. This could be equivalent to the runtime of the server if a server-script locked the object.
2.) never ever lock your objects recursive unless you need to
In most cases a non-recursive lock is want you want, so you should get into the habit of only using recursive lockings when you need them. Recursive locks may make sense if you:
want to lock a Page including all Sections
want to lock a folder and all childrens to perform a bulk operation