diff --git a/src/openpgp.js b/src/openpgp.js index 6d6b06d4..495ea9e8 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -89,10 +89,12 @@ export function getWorker() { /** * Cleanup the current instance of the web worker. */ -export function destroyWorker() { - if (asyncProxy) { - asyncProxy.terminate(); - asyncProxy = undefined; +export async function destroyWorker() { + const proxy = asyncProxy; + asyncProxy = undefined; + if (proxy) { + await proxy.clearKeyCache(); + proxy.terminate(); } }