Extract private deactivate function