Recent history shows that major wars usually end with talks establishing agreements and settlements to end the conflict, with one side typically emerging victorious. In the case of a wider stalemate, war is typically used to enhance the negotiating positions of both sides ahead of any settled agreement to end hostilities.
Inevitably, all wars must end, and warring parties need to come together to negotiate the terms of victory, surrender, or other agreements and settlements. Surviving parties are left to negotiate whether they are the winners or losers of the war.
Throughout history, nations have shaped peace through diplomacy, dividing up resources and territories, establishing spheres of influence and setting up mechanisms for unresolved issues. History is awash with treaties that outline these matters, such as the Treaty of Westphalia in 1648. The Congress of Vienna in 1814-1815—which ended the Napoleonic Wars with France's participation, even after it lost—ended up reshaping the geopolitical landscape of that era.
Then, you have the Treaty of Versailles, which ended World War I and extended to the Yalta Conference in 1945, where Allied leaders laid the groundwork for the establishment of the United Nations and the post-World War II international order. For its part, the Cold War between the United States and the Soviet Union ended without a formal treaty or agreement. Instead, it ended because the Soviet Union simply disappeared, leaving Washington with no counterparty to negotiate with.