Peter is right, but his solution is overly complicated and wasteful on resources.
From the description of your application I am not totally clear on the layout. So I will assume that you are using threads and not some other method of splitting your application into multiple processes. If you are using some thing else then please let us know.
As to a solution I would use g_idle_add() which is in Glib to add a call back function which will then be called in the GUI thread. Note that Glib is thread safe and will perform any locking that is needed.
/* call-back function that will close a window */
/* This will be called when GTK has nothing else to do */
/* or use this to quit the GUI main loop */
/* gtk_main_quit (); */
/* code in another thread */
As a note gtk_timeout_add() which is what Peter suggested to use has been deprecated since GTK+ 2.4, with the two series now on 2.24.9. If you do need it then you should use g_timeout_add() instead. Note that this is resource wasteful as it will be a busy loop looking at changes in a variable every loop, and you could be using that CPU time for your real-time application instead. Note that Peter had missed out the locking that is still needed.