Added a 'quit' request and moved the exit handling into the common library.