Using g_io_channel_shutdown() and g_io_channel_unref() for teardown (untested)