The "alias" frequencies you see appearing above the Nyquist limit $f_s/2$ do not exist in a proper interpretation of the digitised signal; they are appearing due to incorrect interpolation of the samples during reconstruction. If you correctly interpolate the signal from the samples, those frequences will not be there.
Remember, a key condition of the Nyquist–Shannon sampling theorem is that it can perfectly record the input signal only so long as it contains no frequencies above $f_s/2$. A corollary of this is that the output signal you produce from correctly interpreting the samples must not contain such frequences either. The core of the theorem is that if you sample a signal under this condition, and then plot a sequence of points corresponding to each sample, there will be only one curve you can interpolate that both passes through every point and also contains no frequencies above $f_s/2$; that curve is the same as the original input.
The difficulties and details of adhering to this condition and properly interpolating the output are what cause problems like the one you're seeing.
In the case of your output, you're probably reconstructing the signal using piecewise interpolation, producing a "stair-step" output that looks like this:
(Image credit: https://wiki.xiph.org/Videos/Digital_Show_and_Tell)
That's certainly one way of doing it, but it (or at least it used alone) is the wrong way. Such an interpolation clearly has a lot of frequency information above $f_s/2$ (the alias frequencies) and is significantly different the original input signal meeting the conditions above.
It is, however, often an intermediate signal during the interpolation process; it turns out that one way of doing the interpolation fairly accurately is to to generate a signal using piecewise interpolation and then filter out all components of it above $f_s/2$, which will leave us with the original waveform.
You can do this in your first diagram by simply erasing everything above $f_s/2$, leaving only the original 5 Khz frequency you sampled.
For a more in-depth explanation of this, I recommend Monty Montgomery's, "D/A and A/D | Digital Show and Tell" video (also on YouTube). There's also a text version if you're short on time, but the video demonstration is signifantly more clear. I would consider this almost mandatory viewing for anybody involved in any details of digital sampling, audio or otherwise.