fixed segfault on connection close