What if you added a lot of "error-checking" code that kills the host when it doesn't produce enough of the valuable chemical? I'd guess this is very difficult in practice.
Or also add a competing organism that "triggers" when the concentration of byproduct is too low?