Check that context still exist

Just check that the associated template context for a widget still exists
before trying to execute a given callback on it.

Fixes #1232
Closes #1233