Unexpected changes in plans are uncommon, but do sometimes happen. As a guest, the host can ask you to leave at any time and for any reason (or no stated reason at all). Likewise, a guest can of course leave at any time for any reason (or no stated reason at all). Always try to inform your guest or host of any changes in plans (or the possibility of changes in plans) as far in advance as possible.
Although sudden changes in plans should ideally be communicated in advance, that is not always possible. For this reason, regardless of whether you are a guest or a host, it is always a good idea to have a backup plan (or two)!