Switch to just setting a flag in javaSessionFail and freeing the context in browseCurrentBuffer
This seems to fix some of the heap corruption issues,
however the js context probably needs to be freed after some of the event
handler calls as well.