Socket.io comminication when app is going background or closed

That’s exactly what I’m saying. The socket id changes, so you have to use another id. Use the mongodb Object Id that references each user. This is a unique id that is not supposed to change.
By default, each server-side socket joins the socket.id channel. So make your sockets join the matching mongodb id when it connects.