According the the first of thermodynamics, energy is neither created nor destroyed, energy is simply converted to other forms of energy. So in this case, heat is also a type of energy so when it flows out of the system, therefore this means that some of the initial potential energy was converted to heat and then flowed out of the system. Therefore potential energy will decrease.