$NetBSD$

--- main.c.orig	2010-06-23 08:37:56.000000000 +0000
+++ main.c
@@ -55,6 +55,7 @@ GdkPixbuf *questionmark;
 GdkPixbuf *coverlayer;
 gchar *last_canteen = NULL;
 int sched_seek = -1;
+int shutting_down;
 
 GdkPixbuf* scale_width(GdkPixbuf* pb, float nw) {
   double width = gdk_pixbuf_get_width(pb);
@@ -352,7 +353,7 @@ guint64 pos_within_track(int tr) {
   return secs;
 }
 
-void pause() {
+void ap_pause() {
   GtkWidget* pausebutton = GTK_WIDGET(gtk_builder_get_object(builder, "tool_play"));
 
   gst_element_set_state(pipeline, GST_STATE_PAUSED);
@@ -577,7 +578,7 @@ void next_cb() {
 }
 
 void stop() {
-  pause();
+  ap_pause();
   gst_element_set_state(pipeline, GST_STATE_NULL);
   jump_to_track(0, 0);
 }
@@ -597,10 +598,12 @@ void seek_cb (gpointer seekbar) {
 
 void pause_cb(gpointer seekbar) {
   if(!playing) play();
-  else pause();
+  else ap_pause();
 }
 
 gboolean progress_timeout_cb(gpointer seekbar) {
+  if (shutting_down) /* seekbar can be already invalid */
+    return false;
   if(loaded) {
     g_signal_handlers_block_by_func(seekbar, seek_cb, seekbar);
 
@@ -861,6 +864,7 @@ main (int argc, char *argv[])
     gst_element_set_state(pipeline, GST_STATE_NULL);
     gst_object_unref(GST_OBJECT(pipeline));
   }
+  shutting_down = 1;
   g_object_unref (G_OBJECT (builder));
   g_object_unref (G_OBJECT (gconf));
 
