Warhammer 40k is a perpetual Downer Ending, there is no way to resolve the problems plaguing the galaxy that results in anything other total annihilation of everything.
A happy ending scenario follows: By some miracle, the Emperor is reincarnated a final time as the remnants of his soul escape that monstrosity that the Empire has been feeding in the Golden Throne for 10,000 years, which is revealed to be a nascent Chaos God of humanity's creation. After a lengthy proving ground, the Emperor is confirmed and resumes leadership, purging much of the murderous, self-destructive Chaos-ridden beauracracy of the Imperium. Further, seeing that the true threat not only humanity's further existence, but the galaxy's in general is not so much the forces of Chaos, but the impending simoltaneous galaxy wide Tyranid invasion, he orders the construction of Von Nueman-esque automated battlefleets surrounding the galaxy to fend off the Tyranids for a few centuries or a millenium longer while he rallies the forces of order within the galaxy, his own Space Marines, the Eldar, the Tau and other minor races so that they can provide a united front against inevitable Tyranid threat. That being done, he once again turns inward and commits mass purges of Chaos Hotzones and sets about closing the Eye of Terror and rebuilding the natural barrier between the Warp and Reality. Following on he further utilizes the alliance with the Eldar to improve upon and strengthen the Empire's training of Psykers so that a thousand years further down the road of history, humanity begins to produce their own equivalent of Warlocks and Farseers, with psychic power no longer being feared as an abomination. Finally, again with the help of the Eldar, in fulfillment of the agreement that lead to the alliance in the first place, the Emperor leads a retaking and mapping of the Webway, repairing and rebuilding where needed and purging Chaos from those areas where the Webway has failed. Which leads to a final confrontation with Slaanesh, himself the architect of the last 20,000 years of misery and horror that sees him either obliterated by the combined might of the Emperor and the Eldar or fully installed as the Chaos God of Hedonism and the removal of his need to feed on Eldar souls.
TLDR; The worst possible fanfic you could think of for 40k.