It is just a convention, not a rule. It is very common in classical music for a piece in a minor key to end on a major chord (called a Picardy 3rd) or in some cases to end on the dominate 5th - which is a major chord. The latter though, isn't usually the absolute end of a piece because it leaves you hanging (rather like ending "Happy Birthday" on the word "to" - and leaving off the "you").
That makes it sound like a definitive rule, but it's just a common convention.