 The alliance with the United Kingdom during the Peninsular War of 1808–1814 failed to prevent the deterioration in the town’s fortunes.The arsenals and fortresses were abandoned and they were easily occupied by the French in 1809.When the war with Napoleonic France was over, many of the South American colonies chose to break apart from their mother country and the shipyards of Ferrol went into a serious decline losing most of its civilian, clergy and military population, and henceforth, by 1824, Ferrol had a population of just 10,000 civilian and about 6,000 military personnel "(stationed locally if not permanently, at least during most of the year)" with its mathematical school for marine artillerists, the pilot school, and Academy for the Guardas Marinas almost completely empty in contrast with the glorious years of abundance known before the Battle of Trafalgar in 1805.