timeEndPeriod must be called with the same timer resolution value used in timeBeginPeriod. When the process exits the timer resolution is restored anyway so this is not very important.