QuitProgram: avoid service calls after dispose

Technically there was no explicit bug here, but calling any method of a
service after the context has been disposed seems best to be avoided. So
this change reorders the execution flow so that the dispose() call is
the last thing to happen (except for maybe a System.exit(0) afterward).