I first though to record the successive positions, then to replay them in the reverse order, but then I ran your code and saw that movement is done in one direction only.
Other problem if you keep the current directional moves: some particles are quite slow, so you can't make them go out of the window in less than 5 s.