Fix multiple timeout events

Originally reported as #4782. For some reason github decided what I want to push to v0.8, so opening new pull request with a test case and suggested fix.