Close endpoints when transport closes

Also remove an endpoint from the list of local endpoints when it is
closed.