Fixes issue that keeps karma from exiting

Added support to explicitly stop the server and middleware when karma wants to exit. Fixes #18