Hacking through phantomjs not terminating properly