fix bug, server not being shutdown on exception due to removal of server smartpointer