It says on the Node.js about page:
Node exits the event loop when there are no more callbacks to perform.
Is there a way to find
You can use process._getActiveHandles()
and process._getActiveRequests()
See this discussion in node.js mailing list.
update: there is a good package for this - https://github.com/mafintosh/why-is-node-running
There is a npm module wtfnode to show what keep the nodejs app running when you sends SIGINT (ctrl-c) to it.
It internal uses process._getActiveHandles()
as mentioned in @andrey-sidrov's answer. The benefit of using wtfnode
is that it provides easy-to-read output.