What you do in the hours before bed and when you do it can have an effect on how easy it is to fall asleep and stay asleep throughout the night. It's often mentioned that adopting a consistent evening routine can help with insomnia, and research finds that certain habits like a warm bath and reducing screen time correlate with quality sleep.
The key here is that there needs to be the understanding that you're using this time to practice to train in mindfulness, not to fall asleep. If the explicit intention is to fall asleep then you set up a monitor in the back of the brain to continually check on that. You need to let that expectation go, it's okay if you don't fall asleep.