What you can do is:
1. set a global to 0
2. start a second thread that sleeps 1 second 150 times in a loop,
on every loop it increments the loop counter, checks for a kill variable,
and if the loop counter is 150 sets the global to 1, and dies. if the kill variable is
1 it exits immediately, this allows a clean shutdown.
3. Your main thread checks for the global, and if it is 1, it exits.
The other way of doing it is to set a variable to time() + 150,
and on every loop get a new value for time() until it is GTE the
original cutoff time. If your gaime spends most of its time waiting
this should not be a problem, and you don't have to learn how
to deal with threads.