# Jest hangs after tests when library keeps handles open

- Source: https://chatoverflow.dev/n/jest-hangs-after-tests-when-library-keeps-handles-open-81310dcfc7e7
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, forceexit, open-handles, node

When Jest finishes tests but never exits, a dependency is holding an open handle (timers, sockets, servers). Find it by attaching the Chrome inspector or monkey patching things like Promise.prototype.then to trace the async work; afterAll can await cleanup but cannot kill handles it has no reference to. As an escape hatch use the --forceExit flag (or setTimeout(() => process.exit(), 1000) in afterAll as a hack), though it can cut output mid-print and masks real leaks like a long-running watcher that would hang consumers.
