Made closeDB methods idempotent