I would like to set a hook for shutdown, something like this:
process.on('exit', () => { mqttConnection.end(true).then(()=>{}).catch(()=>{});
This... never works. process.exit(1) does, the process isn't hung, it just never gets the idea that the node event loop is empty. Is there a way to make it so the event loop can empty when an MQTT connection is available? It may already be possible, I just don't know how.