You're right, the answer should be edited out of the question. Answers belong in answers, not in questions.
As for what to do next, if the question is closed, you have several options:
1. Vote to reopen.
If you feel that the question deserves to be here and to be answered (i.e. it is on-topic, answerable and not a duplicate), then you should vote to reopen it.
Unfortunately, as you've observed, reopen review is kinda broken, with even seemingly obvious cases (like, say, an on-topic question closed as a duplicate of a deleted question) having a pretty low success rate of getting reopened. I've complained about this before, but as long as the queue keeps being flooded with auto-flagged questions that clearly should stay closed, I doubt it will improve.
The work-around is to find some other place with less jaded people that you can ask to take a look at the question. The SOCVR chat room is one such place. (Yes, compared to the reopen queue, it really is!) Meta can be another, as you may have noticed; right now, the question linked from the comments above is one vote away from being reopened.
Of course, neither SOCVR nor meta are any kind of magic cheat codes to bypass review entirely — they just get the question reviewed by a different set of people, hopefully with a more discerning eye. In some cases it might turn out that those people still think the question doesn't deserve to be reopened, in which case they'll probably tell you so, in detail. But at least you'll get some useful feedback, rather than just a list of users who may or may not have glanced at the question before clicking "Leave Closed".
BTW, if you think that the question could be good and on-topic, but is not necessarily so yet, then edit it into shape first before proposing to reopen it! I really can't stress that too much. People will review the question based on what it is, not what it could be, and a poorly written half-off-topic question is unlikely to get reopened even if there's a good question buried inside it.
2. Answer the duplicate instead.
Of course, this only applies if the question is closed as a duplicate (unless you can get it reopened and re-closed, which takes a lot of effort for usually little gain).
The tricky part here is that the answer to this specific closed question may not actually be a good answer to the duplicate, at least not without a considerable amount of editing. Sometimes all it takes is changing a few variable names to match, but sometimes the closed question (and its answer) might be significantly narrower than the duplicate, or perhaps asking about the same problem using completely different terminology. Maybe the duplicate is a general question about doing X in Y, while the closed question is about doing Q (another name for X) in Y in the context of doing Z.
If you feel like spending the effort of editing the answer to make it fit, one potentially useful "framing device" can be to briefly summarize the closed question at the top of the answer (and maybe link to it, for context), something like:
"For the specific problem of doing X (a.k.a. Q) with Y while also doing Z, as in [this duplicate question](link), a good solution is to..."
or:
"The need to do X (a.k.a. Q) with Y often arises in the context of Z, as in [this duplicate question](link). In such cases, one can..."
or:
"To illustrate how to do X with Y, let's say you're doing Z and want to do Q, as in [this duplicate question](link)..."
Of course, even with such a framing device, you still need to ensure that the framed answer really is a useful answer to the question you're posting it under.
If you can't make it so, that could be evidence that maybe the questions aren't truly duplicates after all, if there is a good answer to one of them that doesn't answer the other. You may want to explicitly point that fact out when proposing to reopen.
3. Find a better duplicate (and maybe answer it).
Sometimes, you might discover that the question is an exact duplicate, but not really of the question which it was closed as a duplicate of. In such cases, it may be useful to note that gold badge holders (and moderators) can edit duplicate links without having to reopen and re-close the question. If you don't happen to have a gold badge in any of the question's tags yourself, you could:
- ask e.g. on SOCVR if there happen to be any gold badge holders around,
- flag the question for moderator attention and ask them to change the dupe target, or
- if the question was originally closed by a gold badge holder (alone), @ping them in the comments (yes, this does work!) and ask them to edit the link.
Of course, if all else fails, you could also just post a comment linking to the better duplicate question yourself. It may not get listed in the box at the top of the question, but at least the link will be there in the comments if anyone bothers to look for it.
4. Just let it be.
Sometimes, it might be that there is no good place for the answer. Maybe the (new) duplicate already has an essentially equivalent answer, or maybe the answer is so tangled up with the OP's code and their specific needs that generalizing it to be useful to a wider audience would require a complete rewrite. Or maybe the answer is just wrong, or the question it answers is off-topic. In such cases, the best solution may be to just edit the answer out and not repost it anywhere.
You may also consider voting to delete the question itself, or at least downvoting it to make it eligible for auto-deletion. Note that SO currently has no delete vote review queue (all we have is the crappy old 10k tools page), so random single delete votes on old questions are even less likely than reopen votes to actually achieve anything. Again, SOCVR is your friend here.