Anyway the office for foreigners said I needed to leave the shengen territory before my 90 days and then come back and show them my stamp
I will make 2 assumptions and would advice you on this assumptions.
Firstly..I would assume you came into poland without a visa, You are allowed to stay in poland without a visa for 90 days. However it takes 45 or more days to get a tempoary residence permit, so if you applied early for the permit at least 45 days before the end of your allowed stay, you dont need to leave poland to any other country. The permit decision should be ready b4 the 45 days expires. Now Poland has a terrible govt systems, esp when it come to foreigners permits...so if the decision is not ready after 45 days, dont worry, they would issue a visa on your passport until the decision is ready. They are REQUIRED to.
Now if you came to poland with a visa, you are luckier. This is because, at the expiration of your visa, U can begin the count of your allowed visa free 90 days.
Be sure that If you have a work promise, and you have not broken any law (though it makes no difference), U will get your permit.