ContextEngine: avoid crash when closing a big file

It seems that there exists a code path where the assertion fails.
Ideally, this code path should be found, and the code must be fixed at
the right place. But the ContextEngine is complex, so as a quick
solution, it's better to make the code more robust than doing nothing.

https://bugzilla.gnome.org/show_bug.cgi?id=605138