Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Closing an Electron window does not necessarily quit the application. On Windows and Linux, Electron apps generally quit when their last window closes; on macOS, remaining open without windows is normal unless the app is designed to quit. To stop an app, decide whether you want orderly quitting or immediate termination, implement the appropriate lifecycle handler in the main process, then measure which Electron process and background task is consuming resources.

First determine what “closing” means

Users often use “close” for several different actions:

  • Closing the final BrowserWindow.
  • Hiding or minimizing a window while the application remains available.
  • Choosing Quit from the application menu.
  • Terminating a process from Task Manager, Activity Monitor, or another operating-system tool.

These actions trigger different Electron events. A closed window destroys its renderer process, but the main process can continue running, as can utility processes or child processes. A process that remains is therefore evidence to investigate, not proof of a leak.

Check the Electron version used by your application before relying on an API detail. The official app API reference is a rolling “latest” page, while your installed version may differ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Choose the intended platform behavior

Windows and Linux

Electron’s first-app tutorial says applications on Windows and Linux generally quit after all windows close. If your app should follow that convention, handle window-all-closed and request an orderly quit:

const { app, BrowserWindow } = require('electron')

function createWindow () {
  const win = new BrowserWindow({ width: 1200, height: 800 })
  win.loadFile('index.html')
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})

If you subscribe to window-all-closed, your handler controls whether Electron quits. Omitting the listener leaves Electron’s default behavior in charge; the API documentation explains that subscribing lets the application decide.

macOS

macOS applications commonly keep running after their last window closes. The user can later activate the application and the app can recreate a window:

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) createWindow()
})

Do not label this behavior a resource problem without measuring it. A menu-bar app, sync client, updater, or notification app may intentionally run without visible windows. If your product requirement is “quit on every platform,” remove the platform condition:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
app.on('window-all-closed', () => {
  app.quit()
})

That is a product decision, not a universal performance remedy.

Rank #2
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
  • 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
  • 4GB DDR4 System Memory; 128GB Solid State Drive
  • 11.6" HD (1366 x 768) Multi-Touch Display
  • Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
  • Windows 11 Pro

Use the correct shutdown API

app.quit(): normal, cancellable shutdown

app.quit() asks Electron to close all windows and begin the normal lifecycle. Electron emits before-quit; if windows close successfully, it emits will-quit before termination. A renderer’s beforeunload handler can cancel window closing by returning false, so an unsaved-document prompt or other handler may make the process appear to ignore Quit.

app.on('before-quit', () => {
  stopPolling()
  closeChildWorkers()
})

app.on('will-quit', () => {
  // Final synchronous bookkeeping, if needed.
})

Keep cleanup idempotent: shutdown can be requested more than once, and each resource should tolerate being stopped only once.

app.exit(): immediate termination

app.exit() closes windows immediately and skips before-quit and will-quit. It can bypass cleanup that your application placed in those events and can lose unsaved state. Use it only when immediate termination is explicitly intended and you have handled the consequences. Prefer app.quit() for normal user-driven shutdown.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find code that prevents quitting

Search the main-process source for these lifecycle points:

  • window-all-closed: a handler may intentionally keep the app alive.
  • before-quit and will-quit: code may delay or replace shutdown.
  • event.preventDefault(): commonly used to cancel a quit event while cleanup or confirmation is pending.

Search renderer code for beforeunload and event.returnValue = false. Those handlers can cancel a window close requested by app.quit(). Log entry and exit from each handler while debugging so you can see which path is blocking termination.

Rank #3
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.
app.on('before-quit', (event) => {
  console.log('before-quit')
  // Call event.preventDefault() only when you will resume quitting later.
})

window.addEventListener('beforeunload', (event) => {
  if (hasUnsavedChanges()) {
    event.returnValue = false
  }
})

If you cancel a quit event, provide a definite continuation path. Otherwise the application will remain alive by design.

Stop timers, polling, and child work

A renderer disappearing does not automatically stop work owned by the main process. Review intervals, timeouts that reschedule themselves, network polling, file watchers, sockets, worker threads, utility processes, and child processes. Give each resource an explicit stop function and call it from your orderly shutdown path.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
let pollTimer
let worker

function startPolling () {
  pollTimer = setInterval(checkForUpdates, 30_000)
}

function stopPolling () {
  if (pollTimer) {
    clearInterval(pollTimer)
    pollTimer = undefined
  }
}

function closeChildWorkers () {
  if (worker) {
    worker.kill()
    worker = undefined
  }
}

app.on('before-quit', () => {
  stopPolling()
  closeChildWorkers()
})

Electron’s progress-bar tutorial demonstrates the same principle by clearing a repeating interval in a before-quit listener. If you terminate with app.exit(), that listener will not run, so cleanup must not depend on an immediate exit.

Identify the process that remains

Electron has a main process and renderer processes; each BrowserWindow creates a renderer, and destroying that window terminates its corresponding renderer. Other process types can remain, including utility processes and child processes started by your code. Use operating-system process tools to record the process ID, command line, CPU, and memory, then map that PID to your application’s ownership.

From the main process, Electron exposes process-level metrics:

Rank #4
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
setInterval(() => {
  const metrics = app.getAppMetrics()
  for (const item of metrics) {
    console.log({
      pid: item.pid,
      type: item.type,
      cpu: item.cpu,
      memory: item.memory
    })
  }
}, 10_000)

The app API documents getAppMetrics(); its CPU fields follow Electron’s CPUUsage object. The first percentCPUUsage reading is 0; subsequent values are averages since the previous call. Take two or more readings over a known interval rather than treating one value as an instantaneous measurement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interpret measurements carefully

  • Record whether the final window is actually destroyed or merely hidden.
  • Compare the same PID across several intervals and note whether CPU remains elevated.
  • Separate intentional background work from an orphaned child process.
  • Inspect memory over time; a process remaining in the list is not itself proof of a leak.

A practical troubleshooting sequence

  1. Reproduce the exact action. Close the final window, choose Quit, and force-terminate separately. Note the operating system and Electron version.
  2. Check window destruction. Log BrowserWindow.getAllWindows().length and confirm that the expected renderer disappears.
  3. Trace lifecycle events. Add temporary logs for window-all-closed, before-quit, will-quit, and renderer beforeunload.
  4. Inspect cancellation. Remove or resolve preventDefault() and returnValue = false paths that are not required.
  5. Inventory background work. Find intervals, watchers, sockets, workers, and child processes; stop each during before-quit.
  6. Sample metrics. Call app.getAppMetrics() at a fixed interval and record CPU averages, memory, process type, and PID.
  7. Retest normal Quit. Verify that cleanup runs and no owned process remains unexpectedly. Test macOS activation separately if the app intentionally stays resident.

Common symptoms, causes, and fixes

Symptom Likely cause Fix
App remains after closing the last window on macOS Platform convention or intentional background mode Use window-all-closed with unconditional app.quit() only if the product should quit on macOS.
Quit does nothing beforeunload, preventDefault(), or a confirmation flow Trace the handler and complete or remove the cancellation path.
CPU rises after the window closes Main-process polling, watcher, worker, or child process Identify the PID with getAppMetrics() and stop the owning work in before-quit.
Cleanup runs during normal Quit but not forced exit app.exit() skips normal quit events Use app.quit() unless immediate termination is a deliberate requirement.
Several Electron processes remain Expected multi-process architecture or orphaned child work Classify each process by type and ownership before changing lifecycle code.

Performance and reliability practices

  • Do not use arbitrary CPU or memory thresholds as universal definitions of a leak; workload, platform, and app design determine what is acceptable.
  • Keep diagnostic sampling out of production hot paths, and remove verbose logging after reproduction.
  • Make shutdown operations bounded and observable. A network request that can wait forever should have cancellation or a timeout.
  • Close database connections, sockets, file watchers, and IPC channels that your app opened.
  • Test closing windows, application-menu Quit, relaunch, crash recovery, and macOS reactivation independently.
  • Document whether the app is expected to provide tray, menu-bar, notification, sync, or updater behavior after windows close.

Or skip the browser setup

If you need a clean screenshot of your Electron app’s web UI for a bug report or release check, ScreenshotNeo can capture a URL without maintaining your own browser automation service. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

One request is enough (see the ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same endpoint works from Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Or Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo includes full-page and element captures, device and retina settings, waits, custom CSS or JavaScript, request blocking, authentication headers, cookies, geolocation, PDF output, caching, signed links, asynchronous webhooks, bulk capture, and a usage API. Every plan includes the features. The Free plan provides 1,000 screenshots monthly with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

FAQ

Does closing a BrowserWindow always stop its renderer?

Destroying the window terminates its corresponding renderer, but the main process and other Electron-managed or child processes may continue.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I safely call app.exit() after every close?

Only when immediate termination is intentional and you have handled unsaved data and cleanup yourself; it skips before-quit and will-quit.

Best Value
Sale
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.

Why is the first CPU metric zero?

Electron defines the first CPU reading as zero because later readings calculate an average over the interval since the previous call.

Should a macOS app quit when its window closes?

Not necessarily. Staying resident without windows is a common macOS convention, especially for apps with menu-bar, notification, synchronization, or quick-reopen behavior.

Frequently Asked Questions

How do I stop an Electron app that ignores the Quit command?

Trace renderer beforeunload handlers and main-process quit listeners for cancellation, then use app.quit() after resolving the confirmation or cleanup path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I record when reporting an Electron process issue?

Include the operating system, Electron version, exact close action, remaining process IDs and types, and CPU readings collected over a known interval.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$249.99
Bestseller No. 2
Dell Latitude 3190 11.6' HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
Dell Latitude 3190 11.6" HD 2-in-1 Touchscreen Laptop Intel N5030 1.1Ghz 4GB Ram 128GB SSD Windows 11 Professional (Renewed)
1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core; 4GB DDR4 System Memory; 128GB Solid State Drive
Bestseller No. 3
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$289.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.