pipeline children not changing to GST_STATE_NULL state when dynamically added

pipeline children not changing to GST_STATE_NULL state when dynamically added

If I do this:

-create a new pipeline with some elements
-set the pipeline state to GST_STATE_PLAYING
-dynamically add a new element X to the pipeline
-set X to GST_STATE_PLAYING using gst_element_sync_state_with_parent()
-set pipeline state to GST_STATE_NULL

I find that element X doesn't change state to GST_STATE_NULL.

Is there something I can do so that element X would indeed change with the
state of the pipeline?