If you're an avid user of Gmail like I am, there are plenty of protections against accidentally sending your boss an email. First, there is the great Undo Send feature that can delay the sending of your email for up to 30 seconds, then there's the Gmail feature that's like sobriety test for emails — Mail Goggles.
Although this neat feature is meant to prevent another, "Oh my god. Don't tell me, I drunken emailed him again!", it can actually prevent some office no-nos. For example, when it's really late at night and you're really tired, you might not realize that you're typing your boss's email address in the sender field. If you enable Mail Goggles, it'll give you some simple math problems to do to make sure you're in the right frame of mind before sending an email. The best part of it is, you can time it so that it's only active during certain times like after midnight.
Although Mail Goggles is a really useful tool, my best piece of advice to prevent this email blunder from happening is to stick to the rule of only sending emails during the day.