The only way to quit gambling for good is to eject it from your everyday life, dont think you can control it, that is just an illusion, forget about it, stop gambling and begin to do other stuff to entertain you.
I totally agree with you, research has even proven that when you repeatedly do something for more than six times you form a habit from it so it's just a matter of stopp bf completely and forming new habits of doing other things apart from gambling. Just try to stop for more than six times and you're sure going to be able to avoid it.