Summary:
Wars can end automatically when one side has been destroyed because it has lost its last city. Or the combatants can agree to halt hostilities short of this unpleasant eventuality through diplomatic negotiations. You or your opponent may choose to initiate such discussions. See the section on Diplomacy for details. Barbarians cannot be negotiated with. You'll remain at war with them as long as they're around.