changed deprecated page.release to page.close. Also changed check to avoid phantomjs crash in onResourceRequested