destroy method
Destroys the thread and cleans up any resources.
This method should be implemented by subclasses to perform any cleanup necessary when the thread is no longer needed.
Implementation
@override
void destroy() {
worker.postMessage({'mode': 'kill'});
worker.terminate();
}