Ensure that the heartbeat thread reference is returned
Fix a memory leak when sessions would be interrupted.