Applied @kdrvn's synchronous-write workaround for premature termination of phantomjs