When dealing with a complex event based algorithm, you may find this workaround useful. Somewhere before the algorithm starts, put:
setInterval(() => {}, 30000);
This will prevent node from exiting.