no break em dash problem

Okay, I need some help getting an em dash to work properly. When I export a pdf of my manuscript, there are places where the em dash at the end of a quote ends up on the next line. Like so:

 "Line of dialogue that gets interrupted but we're at the end of a line so

—"

This looks terrible to me. How do I fix it, make it attach the em dash to the word in front of it instead of the quote. Help!

I posted the same problem a while ago and got two very useful solutions (Mac & Windows). Please check this thread:

https://forum.literatureandlatte.com/t/improved-spanish-dialogue-handling/24751/2