fix segmentation fault cause by db when close program