Catch signals and stop the web server correctly.