This question is motivated by stories claiming that some Republicans are asking Trump to step down as the party's candidate, but my question is for the more general case.
For example, suppose that either Hillary Clinton or Donald Trump developed a severe physical impairment before the November election which left them incapable of fulfilling the requirements of the presidency.
Then, what is the final date for the Democrats or Republicans to change their candidate on the November ballot? Also, if that date has passed, does the VP candidate automatically become the party's nominee?
I found questions similar to this for 3rd party candidates, but not for the 2 major parties.