According to https://support.mozilla.org/en-US/questions/1111123 :
In the about:config page there's an option named middlemouse.contentLoadURL. If you set that to false, it seems to stop the middle mouse click from going back to the previous visited website.