Uneven or slanted wall- stuck
Click on the image to open
Click on the image to open
Click on the image to open

I decided to make a customized closet. I built a shelf section first. When I go to attach it to the wall, I noticed my closet is not flushed against the wall. On the bottom it is, but on the top, it is about an inch away on the back. A similar thing is happening on the right side as well. I made sure everything that I did was level and precisely measured. So this is not the concern. I am thinking it is a slanted wall. Simple caulking is not going to this problem. How can I get this section flushed to the wall on both sides and keep it leveled?