The rival South Caucasus neighbors Armenia and Azerbaijan look set to finalize a historic peace deal after agreeing on the final text of a treaty that would end more than three decades of hostilities.