To thrash someone within an inch of his life is sometimes referred to has beating seven bells out of him. But why should seven be the number chosen? This source here acknowledges the phrase exists but is silent as to the etymology, and here the phrase appears as kick seven bells... and alternatively ten bells, which I have never come across.
I've heard it suggested that the term derives from seven bells, the nautical expression for half-an-hour before the end of the watch (so one would beat someone within a small space of the end of his life). But how do we reconcile that with the alternative beat seven shades (of shit) out of?