Imagine the reaction A + B <-> C+D where the forward reaction is exothermic. If we increase the temperature of the surroundings, the equilibrium is going to shift to the direction that reduces the temperature. Since we know that endothermic reactions take in heat from the surroundings, and so make the surroundings colder, this means that the equilibrium is going to shift to favour the endothermic direction in order to counteract the increase in temperature. That means the reaction will go in the backwards direction and so produce more A+B.Using the same idea, if we decrease the temperature of the surroundings, the equilibrium wants to shift to increase the temperature, so it will shift in the exothermic direction which gives off heat. That means the reaction is going to go forwards, and so produce more C+D.