make use of context_free function

In error case the context is freed without freeing its members.
Use the existing context_free function, which was unused until now
to free the context and its members.