Why did my glass pot explode when I boiled sugar in it and added cold milk?
Assuming initially your glassware contained a cup of sugar and a little of water, you basically prepared caramel.  Depending on the sugar employed, temperatures needed to trigger caramelization vary, but $\pu{160 ^\circ{}C}$ ($\pu{320 F}$) mentioned succrose, as example (which is the normal household sugar) is quite high. Most materials, including glass, dilate upon heating, which is fine as long as this is evenly done.

Now if you add cold milk, say of $\pu{20 ^\circ{}C}$, the glass aims to contract back to its initial state. Because of the quantity of milk added, and the large heat capacity of water as a major constituent of milk, milk served momentarily as considerable heat sink.  Now taking into consideration that the glass ware's walls are unevenly heated -- at the outside still heated by gas or stove to more than $\pu{160 ^\circ{}C}$, and the inner of $\pu{20 ^\circ{}C}$, this suddenly generates a lot of mechanical strain and stress on the material.  The more the walls of your glass ware are thick, the more easy these may then crack and shatter into pieces just by the sudden temperature change.  (For the same token, you place hot glass ware on a plank of wood to allow slow cooling to room temperature.)

In addition, if the glass ware were closed tightly just after addition of the cold milk, the hot ($\pu{160 ^\circ{}C}$) is able to boil off the water in the milk, too; generating steam that likes to expand, or -- if confined in volume -- will build up pressure.  Under normal circumstances, for each litre of (liquid) water, up to $\pu{1.7 m^3}$ of steam may be generated (at normal pressure). This represents an additional stress for the material, and standard kitchen glass ware is not designed to withstand such pressures.