Fixing bug where res.isClosed() was not checking the correct property