http://www.atf.gov/publications/firearms/nfa-handbook/
Chapter 2
"The overall length of a firearm is the distance between the muzzle of the barrel and the rearmost portion of the weapon measured on a line parallel to the axis of the bore."
The handbook doesn't specifically address folding stocks or collapsible stocks. So long as the stock is attached to the firearm and can be extended, the "rearmost portion" would be in the fully extended position. If the stock is permanently fixed in the folded/contracted position, the rearmost portion would be shorter.
Some STATE governments choose to measure everything with the stock folded to increase the number of otherwise legal firearms they can ban.
There is also still a lot of confusion over the impact of Title 18 of the US Code (18 USC), Chapter 44 Section 922(r) which only affects imported firearms, but requires that folding stocks be permanently fixed in the open position.
If you remove the stock, the overall measurement is made from the muzzle to the "rearmost portion" of the firearm...whatever the rearmost portion happens to be. A pistol-gripped (PGO) shotgun has to have a barrel length of at least 18" as a shotgun or it is a SBS. But if the receiver and stock don't add another 8" of length, the barrel has to be longer to make up the difference, or it is STILL a SBS.
Of course, the ATF may decide to 'change' all of that with their next round of opinions. Who knows?