Node.js - Concurrent SQL queries crashing server

I have a basic Twitter-like app which works fine when one user is online. However, when more than one user comes online and tries to perform an SQL query the server crashes.

This is happening because the function closes the database for the first user while the second user is still mid-function, then the second user tries to close the already closed database, leading to a crash.

Here's a basic function as an example:

function showAllUsers(req, res){
  dbConnect();
  var query = 'SELECT * FROM USERS';
  connection.query(query, function (err,rows,fields){
    if (err) {
        throw err;
    }
    dbClose(req,res);
    console.log(rows);
    res.render('allUsers', { user: req.user, message: req.flash('info'), users: rows })
  })
}

I'm using the mysql package from npm, but I'm assuming I'm not using it correctly. I'm currently opening the database before each query and closing it immediately afterwards.

Is there a safer way to do this, or can I just leave it open until the server quits?

Using connection pools solved this issue for me.