Kernel makes it possible to persist and reuse browser sessions. Browsers not marked for persistence are automatically terminated after your action ends, or the you call browser.close() on a remote browser.

To terminate a persisted browser, delete it using the browser ID that you specified when creating the browser with persistence:

kernel browser delete <persistent_browser_id>

You can also do this by making a DELETE request to Kernel’s API:

const response = await fetch(`https://api.onkernel.com/browsers?persistent_id=${browserId}`, {
    method: 'DELETE',
    headers: {
        'Authorization': `Bearer ${process.env.KERNEL_API_KEY}`,
        'Content-Type': 'application/json'
    }
});

Or via the SDK:

import Kernel from '@onkernel/sdk';
const kernel = new Kernel();

await kernel.browsers.delete({ persistent_id: 'persistent_id' });

See the CLI reference for full details.