unified close functionality