Close counting activity in case of database errors.