try connection.on_shutdown ... needs more work