Is there a fee for cancelling a building?
I always thought that if you cancelled a building while it's being built, you got all your mineral back, but I read that the extractor trick for zerg costs 6 minerals when you cancel it.
Does this apply to all buildings/races? How is that fee calculated?
You get 75% back of the cost, minerals and gas. So if you cancel a building that costs 200 minerals and 100 gas, you'll get back 150 minerals and 75 gas.
An extracter cost 25 minerals, 25% of it is 6 (after rounding), so that's what you lose for canceling it.
Notice that this only applies to buildings - canceling a unit or an upgrade gives back the full amount of minerals and gas spent.