As heat is removed....
Technically "heat" is the transfer of thermal energy. When heat is removed from a substance at its freezing or boiling point then a phase change can occur at a constant temperature, and a gas condenses or a liquid freezes.
For example, consider steam which is maintained at 100C and is in equilibrium with the liquid state. If heat is removed the steam will condense to the liquid phase at 100C, and the liquid will begin to cool as more heat is removed.
If heat is removed from a substance between the temperatures of its phase changes, then it cools down. The temperature decreases. The kinetic energy (energy of motion) is directly proportional to temperature, therefore, the kinetic energy of the molecules decreases.
For example, consider water at 50C. If heat is removed, the temperature begins to decrease and the average kinetic energy of the molecules decreases.