implement close flow