If you know "for sure" that a project will not succeed, your responsibility is to minimize the damage - which usually means the cost of termination. (Potential damage could also come in the form of hazards, environmental impacts, etc, so those need to be minimized as well.)
The correct course of action in this case is to assemble a case for why the project is irrecoverable, and then make a recommendation for termination and disposal of materials. The ultimate decision rests with the project sponsor or appropriate decision authority.
It is possible that a project manager may be directed to continue a project that he or she believes is doomed, for reasons outside the project manager's control. In that case it is extremely important that the project manager communicate the costs and risks of continuing and the likely outcome.