 Upon Charles' defeat and death at the Battle of Nancy in January 1477, Duke Adolf was released from prison by the Flemish, but died the same year at the head of a Flemish army besieging Tournai, after the States of Guelders had recognized him once more as Duke.Subsequently, Guelders was ruled by Habsburg Holy Roman Emperor Maximilian I, husband of Charles the Bold's daughter and heir, Mary.The last independent Duke of Guelders was Adolf's son Charles of Egmond (1467–1538, r. 1492–1538), who was raised at the Burgundian court of Charles the Bold and fought for the House of Habsburg in battles against the armies of Charles VIII of France, until being captured in the Battle of Béthune (1487) during the War of the Public Weal (also known as the "Mad War").