 He maintained order in the Mexican capital and indirectly helped envoy Nicholas Trist negotiate the Treaty of Guadalupe Hidalgo, which brought an end to the war.Scott was a candidate for the Whig presidential nomination in 1840, 1844, and 1848, and he finally won the Whig presidential nomination at the 1852 Whig National Convention.The Whigs were badly divided over the Compromise of 1850, and Pierce won a decisive victory over his former commander.