unlock mutexes when thread is cancelled