I believe I can explain why there is energy needed to break intermoleculares bonds and getting into a gas or liquid, but the other way around confuses me. Bonds have potential energy associated to it, so It's needed work to break the bonds, because we would be trying to move a molecule away from a lower potential energy to a higher, like lifting an object. (Is that correct?) Now the other way confuses me, if the molecules get less kinetic energy when heat is transfered to the outside of the system, and than they get closer together so the bonds "stick" or if the bonds being created is what gives heat to the surroundings. If I'm completaly wrong in those explanations please let me know and explain it to me, or refer me to an adequate material.