This type of killing happens several times a week in the US. There are rules when leathal force can be used, when the police officer feels 'threatened'. But the rules are ignored and the definition of threatened is ambiguous. In this instance, the victim removing his hat had police led the police to feel their lives were in danger.
The law is very strange in the US, fortunately our gun laws are far more stingent, and our police do not routinely carry guns.