Add server shutdown and lost connection handlers;