8051 Stop Mode -- External Interrupt Polling?
You have a to do a little more work here. First off it would be needed to detect when the switch has been pressed for "at least 5 seconds". But before you trigger the STOP event you will need to poll for the switch being released. Make sure to poll for the released state properly so that you filter out any possible switch contact bounce that can occur as the switch is released. If you do not filter properly the switch bounce can come right back and trigger the WAKE back up interrupt trigger. You could even be rather conservative and filter for the switch release for as much as a quarter of a second.

One additional thing to consider is to investigate if the WAKE interrupt condition can be turned off most of the time and only armed when you have fully polled for the released switch state.