Use g_io_scheduler_push_job() instead of g_thread_create(). When the
operation is finished, call gtk_main_quit() from the main thread using
g_io_scheduler_job_send_to_mainloop().
Also, check for cancellation with a GCancellable instead of a boolean.
Note: We really should be using GLib's process spawning API
instead of system(), but that's a job for another day.