I don't know if you can stop dogs from doing this. What I did was put the litter boxes in a spare room and gated the door to that room. One night when walking up the steps to go to bed, I noticed the gate was down. The dogs had already gone upstairs before me. I immediately thought, I know where they are. I slowly walked into the room and snuck over to where the litter boxes were. There were my two dogs, side by side, one head in each box. I yelled, get out of there. They both turned their heads to look at me and headbutted each other. It was actually kind of funny.