Database_close modified to reduce memory leakage