If you mess up, confess it to God and ask His help; but ideally you want to stop the behavior. This is why I tell people the best cure is getting out of your comfort zone; give your mind new challenges. Your brain has formed pathways that make it respond a certain way to certain stimuli. These pathways need to be changed and the best way to do that is to put yourself in a new situation that challenges you to get your mind off sex and onto something else. This is tough medicine and most people don't want to hear it, but I can testify it works. After awhile, you'll be able to resume somewhat of a normal life but it takes time; you'll just have be the judge of how long you need.
Romans 13:14 says: "But put on the Lord Jesus Christ, and make no provision for the flesh, to fulfill its lusts." And Matthew 5:29-30: "If your right eye causes you to sin, pluck it out and cast it from you; for it is more profitable for you that one of your members perish, than for your whole body to be cast into hell. And if your right hand causes you to sin, cut it off and cast it from you; for it is more profitable for you that one of your members perish, than for your whole body to be cast into hell."
If your home is providing you with a private space to satisfy your lust, get rid of it if you have to. If your phone cause you to stumble, get rid of that too. Sell off everything and become homeless if you have to. Being homeless will definitely challenge you in ways you never dreamed of. But you have to have a 100% commitment to the Lord or you won't stick with it. You have to have a reason and a hope that something better awaits.
There's a common misconception out there too, that men have to have a release or it's harmful for them physically. Actually this is a lie. The longer a man goes without it, the more his drive starts to shut down making things much easier.
Anyway, that's is my 2 cents; whoever has ears, let him hear.