Server ends without segfault

Previous fix causes segfaults