Update 2011:
To actually close all projects upon exit, you need a plugin similar to the one mentioned in this thread :
I implemented shutdown() my plugin to close the whole project and save the workspace.
Note: today you would use the stop() method for AbstractUIPlugin since shutdown() deprecated in Eclipse3.0 +.
In it you call IProject.close() .
But you also need to set the org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT parameter (the one I originally mentioned below) for Eclipse not to try to restore these editors when you restart Eclipse.
If you do not, you will get some exceptions, for example:
Could not restore workbench layout Unable to restore editor - createElement returned null for input element factory: org.eclipse.ui.part.FileEditorInputFactory.
The original answer back in 2010;)
You need this preference (from this JavaTips ) - it does not close projects, but at least clears your workspace:
> General > Editors > Close editors automatically
When any eclipse workspace closes without closing all its editors and reopens the same workspace, it again opens all the editors that were open during the close.
This can slow down the launch of the eclipse.
Therefore, it is better to close all open editors before closing the workspace.
All open editors can be automatically closed by closing the eclipse workspace.

Vonc
source share