BUG: closing server after error can cause segfault