close correctly