Bitcoin tumbles past $40,000, altcoins follow