Added option to dispose and unregister at the same time