They are very similar in length, at least from what I can tell in the photos (I can't see what your toes look like in the 39.5 as photo is cut off, but the 40 is not too long for you, so that's why I initially chose 40 for you), you can probably get away with either size. It's not going to stretch in length. When I'm in that situation where I could wear either length, I go with the width that fits best. I have a narrow foot, so a size smaller is almost always going to be better for me on width, but I have to balance that with length being too short. Width will stretch for a leather shoe, but if you have wide feet you might want the larger size if the smaller one is extremely narrow or it's stiff.
Now the matter of already wearing the 39.5, if the fit is good enough on the length, I would just keep the 39.5 as it's a hassle to sell and you won't get what you paid.