title: Proper termination of GLib main loop based on "quit" flag in C
body: <p>I realize that this may be a novice GLib question but I've had a hard time finding code examples that solve my problem below. So I'd like your recommendations before I head too far down a wrong path.</p>
  
  <p>My code listens for D-Bus messages.  One D-Bus message is a "Quit" message that is intended to instruct the main loop to shut down.  If there were no other tasks in the main loop, a simple solution could be to instead simply call <code>g_main_loop_run()</code> in the code below and have the D-Bus message handling code (not shown here) execute <code>g_main_loop_quit()</code> when the "Quit" message is received.</p>
  
  <p>However, I prefer that the decision to quit be made by main loop, which in turn may perform a variety of other tasks in addition to listening for D-Bus messages.  The following code does this as expected after setting up a working D-Bus server:</p>
  
  <pre><code>GMainLoop *glib_mainloop = g_main_loop_new( NULL, false );
  /* Set up the D-Bus connection to work in the GLib event loop. */
  dbus_connection_setup_with_g_main( dbus_connection, NULL );
  
  /* Run the GLib event loop. */
  GMainContext *glib_context = g_main_context_default( );
  while( quit_indicator == false )
  {
      g_main_context_iteration( glib_context, /*allow blocking=*/false );
      /* Do a variety of other tasks. */
  }
  
  g_main_loop_quit( glib_mainloop );
  </code></pre>
  
  <p>Note: the above is a bare minimum of code to illustrate my question and I'm aware that the "other tasks" in the main loop may be better handled by threads, <code>GSource</code>s, or other means.  For example, there would be obvious busy-waiting or timing issues if the above code were used as is.</p>
  
  <p>My question is: is the above code sample a proper way to accomplish what I want or is there a more "true" GLib way of doing it?</p>