Sorry, it looks like that mission has a bunch of overlapping bugs. The best method to avoid it is not starting it until you have the lute and then doing it in one go.
You can also avoid killing Shadowheart by letting her make the choice. She will choose not to kill the Nightsong on her own.