Sets a flag on the closure to indicate that its calling
environment has become invalid, and thus causes any future
g_closure_invoke() on this
closure to be ignored.
Also, invalidation notifiers installed on the closure will be called at this point. Note that unless you are holding a reference to the closure yourself, the invalidation notifiers may unref the closure and cause it to be destroyed, so if you need to access the closure after calling g_closure_invalidate(), make sure that you’ve previously called g_closure_ref().
g_closure_invalidate() will also be called when the
reference count of a closure drops to zero (unless it has already
been invalidated before).