now can close the connection gracefully