Heat-sinks do function in enclosed boxes.
The role of a heat-sink is to (1) spread the heat from the small heat-generating devices over a larger area, in order that those devices and the things near them don't cook. And to (2) encourage that heat to go away somewhere and not build up to a damaging temperature.
It's nice if the heat all transfers straight into air that then flows out of the box through vents, not warming up the surface of the box itself, but that never happens. In many cases the surface of the plastic box gets pretty warm, very little air circulates through the vents and most of the heat generated is transferred out of the box due to conduction through the plastic skin of the box. In the case of e.g. a laptop PSU, all the heat goes through the plastic skin and none goes out through vents. But it still makes effective use of heat-sinking.
In the case of this google thing the metal can is there for two reasons: EM shielding, and also to spread the heat generated by the chips within the can over the entire area of the dongle. Chances are the SoC gets hotter than anything else in there, and without the can it would make a hot-spot on the plastic surface. In segregating the convection into an 'inside-the-can' loop and an 'outside the can' loop, the can might reduce the overall cooling effectiveness and probably result in slightly hotter chippery overall. But by spreading the heat over the dongle's entire area it will minimise the existence of hot-spots on the outer skin that seek to set fire to your curtains and of cold-spots on the outer skin that aren't pulling their weight in the tast of getting rid of all the waste heat.
But still: heat-sinks in closed boxes do work.