Don't print out too many closing divs

Make sure not to update the $prev_depth variable past MAX_NESTED_DEPTH
(because the div should be closed immediately).