fixing errors in server teardown