I got the bug where I defeated Mirakk for the 4th time, then nothing happens.
To end the quest, go to console and type in "setstage DLC2MQ06 500" that will finish the quest and give you the dragon souls, though Miraak body is gone, so can't loot it.
Then type in "setstage DLC2MQ06 580" which will bring up the altar with the Black Book, and you can reset a perk, then go back to Solstheim where Frea will talk to you.
Hope this helps :)