Fixed error with leaving db.lck on abnormal exit