I think it's a bug when a closed question gets an answer. You can see here what I mean. An answer is posted a minute after the question is closed. I understand the idea, that user probably had started writing answer before the question was closed, but I saw a ten-minutes difference. Isn't it possible to notify user that he won't be able to post his answer to a closed question (the same way that he's notified of new answers, or at submission time)?
This has always been by design. The reason has always been stated as making it so the answerer does not lose their work. Even with this in place, people still complain about losing their answers.
However, there is no real reason as you seem to imply that a answerer would want to take back their answer if a question was closed while they were answering. They will likely still get their votes (possibly more if they are right and that is the only answer posted before close). This has long been a 'gaming' method to get easy rep.
Even if the answerer did decide the answer should not be on a closed question, there is always the delete button.
It does notify anyone mid-compose, and disables the "Post Your Answer" button (at least that's the behaviour I've seen). I believe this works by periodically checking the status of the question - if you time it right, then there will always be the chance of submitting an answer to a question that has been closed. In my opinion, it is better to accept this answer, than throw it away.
Does it hurt anybody? The question taken as an example has been closed as "belongs on meta". The answer given is a valid answer, and maybe that answer would not have been given on meta as the question might have slipped the answerers attention.
The person now earned +1 rep, but was thrown a downvote as he dared to answer unintentionally a question that is not bad, just on the wrong side. I think this is a little too strict.
Now let's suppose the question gets reopened. Should the person be given these 2 points back?
I do think that the community will have to mature in some aspects of closing, voting etc. and remember the reason for the site: helpful information for programmers.