close database on deletion