Basically, schooling is a defence mechanism (don't eat me, eat my mate!). It will be used whenever the fish perceive there might be some need, so not necessarily when they're dangerously stressed, but may simply be when there's bigger fish around, like Sam said. When they feel absolutely secure, like there's nobody in this tank can stand up to me, then they won't feel the need for it. On the other hand, if they're sticking tightly together all the time, never wandering off for a nibble, then they probably do feel a bit threatened+ stressed.