Added exit functionality.

Specified an exit function in the API, wrote a test for it, then wrote
code for it.  Tests pass!