this patch changes the shutdown order. js_finalise() must be called
(gui_quit closes / destroys all open windows, which means it also frees
the js contexts at that point).
Another approach would be to collect all available js context before