From 1812 to 1840, the British, through the HBC, had nearly complete control of the Pacific Northwest and the western half of the Oregon Trail. In theory, the Treaty of Ghent, which ended the War of 1812, restored possession of Oregon territory to the United States. "Joint occupation" of the region was formally established by the Anglo-American Convention of 1818. The British, through the HBC, tried to discourage any U.S. trappers, traders and settlers from work or settlement in the Pacific Northwest.