Fan Spinning Very Loud then Computer Shuts Down

My computer used to work just fine. Until I heard the fan spinning very loud. And now it randomly shuts down. I want to know if this is an issue with my Power Supply Unit or my GPU. I tried to reset the CMOS battery and then turned on my computer but it will just do the same thing. Please tell me what to do next and how can I fix it?
