Garbage collect network sessions

Network sessions must be killed before their own context. This change
makes use of shared_ptr to maintain ownership of the memory.