I used to have a hard time falling asleep too. In recent years, I can fall asleep right after I go to bed. If I have a disease or illness, it takes a little longer to fall asleep. However, I generally fall asleep in a very short time. I think this is because I have learned to cope with stress.
I reckon this is a big part of why writing helps, as rather than letting issues build up in the background, they get brought to the front for processing.