The more thermal energy that is added to a substance, the faster the particles move and the more space they occupy (they spread apart). The more thermal energy that is taken away from a substance, the slower the particles move and the less space they occupy (they become closer together).
I hope this helps!