Alright folks I went to the range today and after about 30 rounds my XD was working fine. The slide stays unlocked after the last round is fired. I don't know what fixed it but here are the few things I did:
I field striped the gun before going to the range.
I was also making sure that my thumb does not touch the slide lock button.
The guy at Academy suggested it may have been a bad mag but it worked just fine with both factory mags.
I have been using Remington FMJ 115g ammo since I bought this gun. The gun may have not broken in properly when I was at the range the last time. I have fired 250 rounds since I got this gun and I can tell that it's getting smoother and smoother. Accuracy of this gun is outstanding!
Someone asked question about rattling - well my XD9 rattles when the slide is locked. Other than that I haven't heard any noises.
Thanks to all who replied