function to end sale or auction- update database