Alternatively you can use a Hook Element.
Add the code to the Hook content. only this:
<div class="after-loop-container">Your Ad Code here</div>
In the Hook List select Custom Hook and in the field provided add: generate_after_loop
Change the hook priority to 5
Set the Display Rules to Entire Site