Add callback to graceful shutdown.
Add passing test for graceful shutdown.