You can use the Metrash Application to track the number of days you are outside of Qatar. I think it is till 180th day mid-night counted, after that penalty may apply based on circumstances. But why risk when you can come early?