Fix missing Unlock in case of JSON encoding error