Refactored web server process management

Also made sure that the child process is killed before exiting in response to "terminate" action.