Prevent database exception on exit