At the close of his life, David's ongoing authority over the nation receives special focus. Despite the earlier events where his son Solomon was already appointed to the throne, David fully maintained his royal status.
The kingdom was considered exclusively his own until a complete forty years of his rule were counted. Because David kept his position as king until the very end, the official years of Solomon's reign only began to be counted after his father passed away [מלבי״ם].