Simple just like this:
[javascript]
<script type="text/javascript">
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/backtocollection");
history.pushState(null, document.title, location.pathname);

window.addEventListener("popstate", function() {
if(location.hash === "#!/backtocollection") {
history.replaceState(null, document.title, location.pathname);
setTimeout(function(){
location.replace("<?php echo $_category->getUrl() ?>");
},0);
}
}, false);
}(window, location));
</script>
[/javascript]