I remember I had a nasty bug with pssm shadows and wait (1).
The pssm_run function internally uses a while() - wait(1) loop for the effect. By calling the same function with (0) as parameter it will deactivate itself - but ONE FRAME LATER, due to the while() - wait(1) loop.

So deactivating pssm, loading level, setting it again in a row caused to not stop the effect and instead have it running twice. Game got slower and slower after soem iterations and eventually crashed at some point.

A wait(1) after level loading fixed this. wait(1). As usual.

While this shadow thingy is sort of specific, the function construct with the while loop is not. Maybe you have such a trap running somewhere.