Added autoclose option. As requested