In order to stop SPWS, user must access any resource on the site with the path containing string "spws-terminate-and-release-cd" (e.g. filename of the resource should contain this string, or name of directory, or even virtual URL handled by Mason). Once request to this resource is performed, SPWS will continue to serve content for additional 5 seconds (to allow that resource to refer to any other content like scripts, stylesheets, images or even multimedia), and then SPWS will terminate, attempting to eject CDROM if it was started from CDROM.
The sample of this functionality is available on demo cdrom.