Using ensure block to release lock