When James I was assassinated in 1437, his young son, also named James, was only 6 years old. Scotland was once more ruled by a Regent. Oh, but it wasn't that simple! The Regent died from the plague in 1439, and nobles wrestled for control of the regency; the keepers of both Edinburgh and Stirling castles fought to keep the young king.
In 1449 James married Mary de Gueldres and took control on his own behalf. That did not stop powerful nobles like William, Earl of Douglas from trying to undermine the authority of the crown and take power for themselves. James discovered that Douglas was plotting against him. He gave Douglas a chance to distance himself from the other plotters, but when the Earl refused, the king flew into a rage and stabbed the Earl to death.
It seems highly likely that James planned to kill Douglas from the start, but that did not stop a Parliamentary inquiry from passively finding that Earl was responsible for his own death by 'resisting the king's gentle persuasions'.
The murder of Douglas might have initiated another era of power struggles, but in fact, it had the opposite effect; James was able to exert royal authority and bring about a period of relative stability.
Then in 1460, James decided to remove the final English thorn in the Scottish paw; the last English stronghold in Scotland was at Roxburgh Castle. He decided to besiege the English garrison at Roxburgh and drive the English out of his realm for good.
Unfortunately for James and for stability within Scotland, the king was standing too close to a huge cannon known as 'The Lion', when it exploded. The king was killed instantly. Even without James, the Scots fought on, and the last English garrison in Scotland finally surrendered.