It happened many times that I wanted to answer a question on SO. I did some research, edited a text, corrected typing errors using Microsoft Word (my English is not particularly good) and created and tested a code example. But when a wanted to post it, I could not, because the question had been closed or deleted meanwhile.
This is very frustrating!
Note: While working on the code example in Visual Studio or on the text in Microsoft Word one might overlook the banner indicating the closed situation.
Suggestion
My suggestion is that if the answer field was visible at the time that you opened a question, you should always be able to send your answer.
The OP can still see the answer and decide to undelete his question or users can decide to reopen the question if they find the answer valuable. In any case it would diminish the frustration.