Technically, it would almost certainly not be "perfectly legal to shoot him." The law varies, obviously, from state to state, but generally speaking if you told the police: "The dude had my blu ray player under his arm and he was about to get away" you'd probably be mumped, whether he was in your home or not. In most cases, the "Castle Doctrine" only removes the "duty to retreat" and applies certain presumptions, but those presumptions can still be overcome. From a practical standpoint, as long as you told the police: "I woke up to a burglar in my home and I was scared for my life and I shot him" you'd almost certainly be in the clear, even if you shot him in the back. So could you get away with it? Probably. Would it be legal? Probably not.
Now, in answer to your question, assuming a hypothetical where I was sure he was trying to run away, I'd let him. Even though he's a cockroach who deserves to be capped, and even though I'd almost certainly get away with it, it's just not worth the risk and legal hassle.