You will firstly need to create a Template Override for the following file:
components/com_users/views/login/tmpl/default_login.php
Once done, open the following file (your override):
templates/MY_TEMPLATE/html/com_users/login/default_login.php
and go to line 81, where you will see the following code:
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
and replace it with:
<input type="hidden" name="return" value="<?php echo base64_encode($_SERVER['HTTP_REFERER']); ?>" />
Hope this helps