RF-12824: end document properly for redirected AJAX request