AWS powers down the EC2 instance creates an image and then boots the instance back. This is to make sure that the image is healthy and is in a consistent state. Because of the reboot, the network connection is lost and so is the Putty connection. There is a way to avoid reboot while creating an AMI as mentioned in the AWS documentation here. With the no-reboot option the file
system integrity is not guaranteed.