Call server_close after thread is terminated