Added a dispose function

Disposes the extension context properly and stops crashes when called by
a "close" function.