Mike, you can learn a lot from past posts here - try the “Advanced Search” function and look for things like “sleep” or “bedtime.”
I can tell you what works for me, to get you started. I usually sleep through the night. I drink a full dose of soluble fiber (Metmucil and Konsyl mixed, 1/2 dose each, is my preference) at dinner time. I take 1 Lomotil tab at bedtime to slow the bowel, and usually none during the day. If things are in any way concerning I bump that up to two Lomotil at bedtime. Lomotil works better for me than Imodium, but others prefer Imodium.
Some folks also avoid eating after (an early) dinner. Others get benefit from a small, fatty meal at bedtime, like a spoonful of peanut butter.