Aha, you did well. Quite similar to what I do. When you are ready to fall asleep and you feel like you made enough repetitions of the mantra or visualizations, just quiet your mind and go to sleep as usual. You can also try to reduce the frequency or repetitions gradually, till it kind of quiets downs, that's another way to do it.