How to PREVENT a toilet from running?
I'm not aware of any device on the market but I could imagine a solenoid valve with us 555 timer chip connected to a water level sensor where it would reach minimum and then start the timer for a minute or so, enough time to fill it. That would do the trick. It could be made battery operated. I wouldn't know how to describe how to build it. It's more electronics than DIY. Setting up the flapper properly is an art form, especially when retrofitting one.