I don't want to reinforce the thought that you did meditation wrong, as my understanding is that there is no wrong or right for meditation.
Just wanted to share that I read the other day a suggestion to do mindfulness sessions in the morning or somewhere in the day instead of short before sleeping. That source (I can't recall where I read it) suggested that problems with sleep can be worsened by that. And I guess for the reasons that you state. Not sure if this is a tipp applicable for you, but the part that I cited sounded to me like you were practicing mindfulness before going to sleep.
On the other hand: personally, I have made good experience with a "body scan" exercise when I have trouble falling a sleep.