Removed unnecessary and wrong database closing when the database couldn't have been opened.