On the death of his mother Margaret in 1356, William became Count William III of Hainault and William V of Holland. But returning from a trip to England in 1358, he was suffering from madness and initially to prevent harm, was imprisoned in The Hague, then in the tower of the Castle of Le Quesnoy, in which he remained for more than twenty years. His brother, Albert, Duke of Bavaria, secured the regency of his States, pending the majority of his son William VI, Count of Holland. Albert of Bavaria did not entertain good relations with particular subjects of Hainaut, he arrested Sir Sohier of Enghien at a banquet and locked him in Le Quesnoy, for causing him umbrage. The peers of Hainaut protested and petitioned the lord of Ligne: in reply, the Duke beheaded the lord of Enghien and seized his lands. In 1365, civil war sparked in Hainaut, which was ended in 1376, by the promise of Albert of Bavaria to found a mass in the church of Le Quesnoy dedicated to the repose of the soul of the lord executed, as well as providing monetary compensation for his orphans.