You detach by leaving. You don't have to say anything.
But if you're going to leave anyway, why not exhaust all the options before leaving? If suggesting that you'd like to have a friend with benefits doesn't work, strike up a friendship with a potential girlfriend, and be open about it. That's not having an affair, though it might be a step to one.
If these steps don't wake up your wife, I don't know what will. If she objects, you can ask, ok, so then you want to work on our relationship? If she doesn't object, well then you can have a girlfriend.
Of course you can always walk away. I could walk away from every relationship at the slightest problem. I have a friend who does that. He's on his 100th relationship or thereabouts. He lost track long ago.