You don’t exit a deadlock cycle. Once you are in a deadlock situation, you lost. You do your best to avoid deadlocks.
With server software, you may be able to have a process that watches other processes and kills them if they are stuck due to a deadlock. Doing this correctly and make your software continue to run correctly is extremely difficult. It’s so difficult that i wouldn’t even try. In addition it is an absolute pain to test (and you don’t want software that isn’t tested). For normal software running in anything from workstation to mobile phone, it’s just not done. Remember that you have two tasks that are trying to do something and one or both of them have to be killed, that is hard to recover from.
What you do in practice: 1. Instead of locking a mutex you check if it is lockable which avoids deadlocks. 2. You add code that detects situations where a deadlock is possible. And if you find a possible deadlock you fix your code. 3. Write sensible code in the first place.