I don't really get the ghost story itself, I get there was wordplay happening but why couldn't he leave?
Mamoru thinks that Takeo's spirit is bound to the earth due to a grudge and been calling out, challenging him in its anger. Feeling guilt he goes to try to make amends. Even if that means accepting his own fate so that his friend may find peace. Instead he discovers that Takeo is actually bound to the earth in a much more literal sense (his spirit having been fused to the fence that killed him) and was actually crying out in pain.
The reasons for why he is stuck within the fence are not really specified, but this reinforces the stories themes that the afterlife works in a more sinister way than our beliefs would let us hope for. The horror lies in Mamoru's realization that he has doomed his friend to endless torment and nothing he does can ever reverse his actions.