Melatonin is considered to be a master hormone. This means that we must get our melatonin balanced if we want our other hormones to be balanced in order to better deal with the changes that come from perimenopause and menopause. 
Discussion
So how is best to take it? Are pills bad if taken nightly?
You donโt need to take it. It is best to create is naturally by waking up and getting sunrise sunlight into your eyes and then protecting your eyes from artificial light at night (this allows your cortisol to drop which allows your melatonin to Rise)
Is it bad to take it? Pretend I've been doing the sunrise thing for a long time but also taking it at night. Also pretend I'm a combat veteran with PTSD that keeps me up at night. ๐
The goal is to not have to take it exogenously. But everyone is an N=1.
My son sometimes uses sleeping melatonin