automatically close on termination