Move implementation into the .cpp; update comment.
Add a test for the graceful shutdown.