The adverbs 거의 and 가까이 have almost the same in meaning when used in talking about a period of time.
In addition, the adverb 가까이 is often used as a noun, meaning either "가까운 곳(or 근처)" or "가까운 때/동안".
"거의 십년에 가까운 동안/기간"
"거의 십년 가까이" (hence, this is a noun phrase, noun + noun)
Thus,
The phrases "거의 십년 가까이-를" and "거의 십년 동안-을" have the same in meaning.