safer db shutdown