How do you avoid nursing baby to sleep?

I’ve been warned to stop nursing baby to sleep. In theory it sounds great...but if I don’t nurse her to sleep, I end up pulling her off because she’s not finished. So she flips out because she’s still hungry and naturally won’t sleep. Help, please!