I tried to follow your advice, but midway my kingdom announced peace with the one I was fighting against.
I logged to an earlier save, and noticed that during the last stage (The Keep) of attack, there was only 6 hours left until a vote for peace, so while technically there should still be time, the game probably ended the conflict in the middle of my attack on the keep.
Which still sounds like an unwanted behavior tbh.
Edit: no that's not it, after taking the castle there is still 6 hours to vote, and the quest is already failed.