terminate worker before calling onerror(), in cases onerror() throws.
Merge branch 'worker_improvement' into integrate