I once heard a great tip to prevent those pre-bedtime snacks. After dinner, brush your teeth as if you’re going to bed. Your brain already associates that with “no more food” and so programmatically dissuades you from eating. It’s always worked for me.