close connection after publish