Put locks in finally-blocks