I was having the same problem and came here for an answer. Just found out there is a very easy way:
window.location.hash = ' ';
Basically you are setting it to '# ', since the space doesn't exist, it doesn't move. When you revisit the page, it also doesn't treat it any differently than just #