March 4, 2022 . 1 MIN READ
// Lets say for example we’re instantiating our browser like thisconst browser = await puppeteer.launch({ headless: false }); // You can simply run this to get the browser’s pidconst browserPID = browser.process().pid // Then you can either store it for use laterfs.writeFile(file, JSON.stringify(jsondata, null, 4), (err) => { if (err) console.log(err);}) // Or just kill the processprocess.kill(browserPID);
Reference: https://stackoverflow.com/questions/66880326/is-it-possible-to-close-a-puppeteer-browser-using-its-contextid