Unlock mutex before function return.