preserve 3rd party values in  in the Session destructor

Fixes #6251 

cc @karlitschek @PVince81 @DeepDiver1975 @dattn