How do you stop yourself from doing things that you aren't supposed to do, but really struggle with?

For example, someone you know orders a pizza. Everyone gets some, but there is a lot leftover and you are struggling not to eat the leftovers.