diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs
index 9e07bf042..92a491c60 100644
--- a/examples/src/bin/gtksink.rs
+++ b/examples/src/bin/gtksink.rs
@@ -134,12 +134,19 @@ fn create_ui(app: >k::Application) {
// Pipeline reference is owned by the closure below, so will be
// destroyed once the app is destroyed
let timeout_id = RefCell::new(Some(timeout_id));
+ let pipeline = RefCell::new(Some(pipeline));
app.connect_shutdown(move |_| {
- pipeline
- .set_state(gst::State::Null)
- .expect("Unable to set the pipeline to the `Null` state");
+ // GTK will keep the Application alive for the whole process lifetime.
+ // Wrapping the pipeline in a RefCell