Depending on the size of the gap, I usually use a flexible decorators caulk to fill it.
Just smooth it down with a wet finger or cloth and let it dry for 24 hours before painting.
If it is a larger gap you could try a couple of screws to try and narrow the gap or just refill with caulk after the first
lot has dried. If you are unsure about making a neat job use some masking tape just above the gap
and remove about half an hour after filling.
Hope that helps