Sleep... How do I retrain my brain to sleep well at night?

Sleep hygiene. Great question. There are many effective ways to do this, but the keys I have found for my patients are to stick to the plan and treat the wake-up time as sacred. Set a go-to-bed time for yourself. Set a wake-up time. No matter what time you actually fall asleep, get up at your set "get-up" time. And no naps during the day! it takes about 6 weeks to train your brain to follow the times you've set.
Sleep hygiene. Basic sleep hygiene involves avoiding stimulants including nicotine and caffeine (including foods containing caffeine) for several hours before bedtime; avoiding alcohol around bedtime; establishing a regular bedtime and rise time; avoiding daytime naps; taking regular exercise, especially in the late afternoon or early evening; allowing adequate time to unwind before going to bed; dark, quiet room.
Discipline yourself. So you have good sleep habits and keep doing them until your sleep is good. Easy to say, hard to do. First be sure there are no medical reasons for poor sleep like sleep apnea, hyperthyroidism, chronic pain & others. Next set up a plan for just what you can do to develop better sleep habits. Your doctor or a counselor dealing with sleep problems can help you. Start now and be persistant.