I'm assuming you're running multiple instances, so here's a way to keep track of them:
let accounts = {};
function loginAccount(accountName, password, twoFactorCode) {
if (accounts[accountName]) {
throw new Error(`Account ${accountName} is already created`);
}
let user = new SteamUser();
accounts[accountName] = user;
user.logOn({
accountName,
password,
twoFactorCode
});
}
function logoutAccount(accountName) {
if (!accounts[accountName]) {
throw new Error(`No SteamUser for ${accountName}`);
}
accounts[accountName].logOff();
accounts[accountName] = null;
}