Close the opened database connections

Also keep the db config in a separate configuration file