Thanks!
'break on' solved the problem. But I find it pretty strange that closing the script while running makes it log off the user.