Is there a way to self terminate a genserver after no activity?

You may want to check out this other thread, which speaks to this. In it, @lehoff mentions:

Do note that the timeout is cancelled whenever a message is received.

Ah, I see @sasajuric has just mentioned the same thing. That thread is still a good resource for a discussion on how exactly to implement the timers if you handle them manually.