Added process exit if the connection to mongodb doesn't work.