add the onCriticalExit callback to handle the case where phantomjs crashes.