Make app shutdown more clean

* Navigator: Close all pages
* JS: Wait for all models to terminate and cancel all pending I/O requests
* Fix a memory leak in page.options settings

Fixes #1909
Fixes #1889