Removed If
Only close session if it's still open