If part of a sentence within parentheses falls within a larger sentence, punctuate outside the closing parenthesis. When the movie came out (starring Tom Hanks, Alice May, and Tim Curry), we all went to see it. I used to think that anything inside parentheses was optional. Let's pretend that's true (it sort of is); a sentence must still flow correctly if you delete everything within the open and close parentheses. We could then rewrite the example as When the movie came out, we all went to see it. If the last comma were inside the parentheses, it would read, When the movie came out we all went to see it. That is grammatically incorrect and fails my test.
If parentheses surround a full sentence, the period must be within the parentheses. The game was late. (But of course we all attended.) It was a good game. The parentheses mark off an entire sentence, which deserves its own period. Applying my test again, we get The game was late. It was a good game.