A flag, whether it is the US flag or a state flag, is generally flown at half mask to indicate that someone of importance has died. In general, it is the President of the United States who orders the US flag to be flown at half mast.
A flag may be flown at half mast for reasons other than people dying. While it is improper to due so due to the US Flag Code, the flag is sometimes flown at half mast by the order of high-ranking government officials other than the president. This may be done to mark some tragedy that has occurred or simply as a commemoration of an important event.