pass reference to the lambda callback of the connection closing