If I want a sound sleep I need to wait about an hour after finishing my ride before I go to sleep. I want to do my summer night rides as late as I can, because each hour you wait gets cooler. This is the compromise I settled on after a few really late rides followed by sitting awake in bed. I also only do about an hour max.
Note that the idea that evening exercise is bad for sleep is an old myth. See e.g.
https://www.health.harvard.edu/stayi...t-affect-sleep where they quote a recent meta-analysis showing the correlation is in fact the opposite in all the studies done, people on average sleep
better after evening exercise. They say after intensive exercise you need to stay awake for an hour, the same thing I figured out by by own trial and error. Of course YMMV, these studies are just reporting averages.