added database close function to die function