Fix segfault by closing server in flared destuctor