It might be a daft question, but what are you doing in your program when the user moves the mouse or presses a key? Are you completely exiting the program or hiding it?
Also, are you setting the initial state of any variables you use at the start and releasing them when you exit?
I don't have the SDK, so my suggestions might be useless - sorry.
I was just thinking that your screensaver might well be kicking in the second time as it should, but the variables which make it exit haven't reset so your screensaver is immediately exiting again.
TDK_Man