I have produced the bug with both Firefox and Chrome on my laptop.
Go to any website which is not Wikipedia, for example https://www.google.com
Go then directly to an image in Wikipedia, for example https://en.wikipedia.org/wiki/Lone_Wolf_and_Cub#/media/File:Lone_Wolf_manga.jpg
Close the image, either by ESC button or by pressing the X button.
Actual Results: It takes you back to the last website in browsing history, https://www.google.com on my example.
Expected Results: It should have taken to the base article which the image is from, https://en.wikipedia.org/wiki/Lone_Wolf_and_Cub on my example.