Controlling the lifetime of a connection