fix invalid memory access upon uv_loop_close