A violent rampage at New York City's Grand Central station ended with police fatally shooting an attacker who wielded a machete, injuring three commuters.