In a graceful shutdown handler you set process.exitCode = 1 and start async cleanup, but you do NOT call process.exit(). After cleanup completes there is no more pending work. What happens?
process.on('SIGTERM', async () => {
process.exitCode = 1;
await flushLogs();
// no process.exit() call
});