The end of David's dynasty came in 587 b.c. , when Nebuchadnezzar, King of Babylon, invaded Judah to lay siege to Jerusalem.
David's dynasty was unstable and nearing its' end even before Nebuchadnezzar's invasion.