Unfortunately for the Habsburgs and their reign, the generations of inbreeding led to the downfall of their European dynasty. Unable to produce an heir to the Habsburg throne, Charles II died at the age of 38 in 1700 (via The Famous People). With no heir, the empire's fate was sealed by a last-minute change to Charles' will, in which he declared that his throne is passed to Philip of Anjou (via Royal Hampshire Regiment). Philip was the grandson of Charles' half-sister Maria Theresa and the product of her marriage to the Louis XIV of France.
The other royal families in Europe had long since been opposed to the French and the Spanish Habsburgs consolidating into one empire, and Philip's ascension to the throne would do just that. Shortly after Philip was crowned Philip V, a war broke out in early 1701 that involved the majority of Europe. Known as the War of Spanish Succession, it ended with the Peace of Utrecht in 1713. As a stipulation of this treaty, no one monarch could hold the crown of both the Spanish and French empires. Philip V continued his reign as Spanish king until his abdication in 1724, after which his son Louis took the throne. Philip regained the throne before the end of the year when Louis died from smallpox. Philip then continued as king until he died in 1746 (via Britannica).