Habits boil down to cues. To get rid of a habit, you address the cues that trigger it.

Finding those cues takes awareness, but once you discover them, circumventing them becomes easier.