Is it possible you have a script responsible for starting and ending WoEs directly invoking the OnAgitStart/OnAgitStart2 label without making use of the agitstart; or agitend;script commands or their @agitstart / @agitstart2 atcommand counterparts (obviously issued by a script or player)?
In that case, both the atcommands and script commands for ending WoEs will be useless because agit_flag or agit2_flag is set to 0, making the server think it's not actually in WoE mode.
What I mean: if you start a WoE directly by the castle event label you won't be able end it by normal means, just invoking the OnAgitEnd/OnAgitEnd2 event label of it.