Fix mutex double-unlock bug