You can't. It is up to you to make sure that the plugin never blocks the main thread and that all threads you start are shut down in time. Congratulations and welcome to the wonderful world of browser plugins =]
Some people have gotten around this by launching an external application that does the real work that won't close until it's done.