shut down db first