Yes, this is a "rule" of English grammar but it has to be understood and applied correctly. The advice to avoid could applies only to those sentences where could refers to an ability to perform a certain particular action on a particular occasion. On this basis, the following sentences are problematic:
? I spent an hour looking for my keys and could find them.
? I could buy the notebook at a good price.
? There was a fire in the building but everybody could escape.
? I played well for a change and could beat him.
In such situations we are more likely to use an alternative such as was able to, managed to, or succeeded in.
Here are explanations and examples from four recent grammars (the first three pedagogic, and the fourth descriptive):
Swan: Practical English Usage
We do not normally use could to say that somebody managed to do
something on one occasion:
? After six hours climbing we could get to the top of the mountain.
Murphy: English Grammar In Use
We use could for general ability. But if we are talking about what
happened in a particular situation, we use was able to or managed to
(not could).
? They didn't want to come at first but we could persuade them.
Carter & McCarthy: Cambridge Grammar of English
When actual achievements are indicated, was/were able to, not could,
is preferred in past affirmative cases:
? The thieves escaped but the police could arrest them later that
evening.
Huddlestone & Pullum: The Cambridge Grammar of the English Language
An important restriction is that could does not normally appear in
affirmative contexts when it is a matter of actualisation of a single
situation viewed perfectively:
? I left early and could get a good seat.
The OP's example sentence is somewhat tricky because staying awake is more of a state than a single action. The following sentence is a more clear-cut example of the application of the rule explained above:
? After lying in bed for hours staring at the ceiling I could fall
asleep.
Better:
After lying in bed for hours staring at the ceiling I managed to fall
asleep.