Make sure that a lock is always released.

Change-Id: Ifbd7972a738381d23d23a62cd645a7c25b8f32df