protect db connections so they always close