Moved server shutdown stuff to on-exit