Backport crash fixes to Phantom::doExit from master

The relevant bits from these commits were applied:
cf12fc4a236e071382e9e6b9c391b606eac17ea1
a9809996b168a5696b917702ccc3696c70e71233
1e7829db97d5134336d6f9e4961c1cfd1d1bf9d5

https://github.com/ariya/phantomjs/issues/11642

https://github.com/ariya/phantomjs/issues/12431
System#os.version should know OS 10.9 Mavericks.

https://github.com/ariya/phantomjs/issues/12579
System#os.version should know OS 10.10 Yosemite.

https://github.com/ariya/phantomjs/issues/12579
Fix building on OS X 10.10 (Yosemite).

Related upstream bugs:
https://bugreports.qt-project.org/browse/QTBUG-39644
https://bugreports.qt-project.org/browse/QTBUG-40612
https://bugreports.qt-project.org/browse/QTBUG-29373

Related upstream commits:
https://qt.gitorious.org/qt/qt/commit/997d6261
https://qt.gitorious.org/qt/qt/commit/b82b8bfa
https://qt.gitorious.org/qt/qt/commit/ea0ab2cd
https://qt.gitorious.org/qt/qt/commit/df35604f

https://github.com/ariya/phantomjs/issues/12622
Update ChangeLog for 1.9.8.

https://github.com/ariya/phantomjs/issues/12670