I?m still struggling with this. With Samba 4 it?s taking roughly 2 hrs 11 mins for a Samba session to be cleared when a Windows 7 machine is shutdown. After this delay it clears the session and runs the ?root postexec? script for the user. I?ve tried setting keepalive and deadtime to different settings (eg keepalive = 600 and deadtime = 10) but they seem to have no effect with this. Maybe these two parameters aren?t relevant, but I?m not sure what other options would affect this behaviour. Windows XP seemed to work okay, so I think it must be something between Windows 7 and Samba. Any ideas?