mongoDB provider fix: close connection on error