Only some references, give some attempts.
Ask Different site: Close empty desktop/spaces [1] [Aug 10 '14]
You can speed this up and hold Option down and this will keep the (x) to close the desktops shown so you don't have to hover over the selected desktop and wait for it to show itself.
... else
The only way that I would think you might be able close them all at once without performing the above process is probably with an automator script or apple script.
"Close Desktop Spaces in Mission Control for Mac OS X Quickly" [2]
There are other ways to close the virtual spaces but, remember, you can quickly close desktop spaces in Mac OS X Mission Control by holding down the Option key, this causes the familiar iOS style and Launchpad (X) close symbol to appear over the spaces which can then be rapidly closed.
"Handy Keyboard Shortcuts for OS X Mavericks" [3]
Close All Windows
Option+Command+W