added a function to destroy a context