I am a self-taught piano player which is why I am asking this. When I end a piece I hold the sustain pedal and then gradually lift it to decrease sound until I finally let go. I recently was wondering if this is incorrect and if you're supposed to just hold it in place and then release it suddenly. Or is either way correct?
The problem with slowly releasing the damper pedal is that it creates an undesirable "womp" sound when the damper as just touching the strings but not yet fully damping them.
The better technique is to keep the keys down along with the pedal, and release both slowly but together, until almost finished. Just at the end, release the pedal fully, but keep the keys pressed. There will be a slight change in timbre, but at that point it will be all but unnoticeable.
Finally, slowly release the keys, and voila.
Because this process is happening slowly, the natural decay of the sound has a chance to play out. But even if the release is faster than the natural decay, it will still have a fade-out effect and with a cleaner sound that doing it with pedal alone.
It depends on what you want at the time.
When the pedal is depressed, you're getting much more than just the notes you played as you deployed it - there's all the octaves of those notes ringing in sympathetic harmony too.
So, by hanging on to just those keys, as you release the pedal, you're bringing the dampers back onto the strings involved, which could be quite a few. More than you pressed down, although the vast majority of them won't be sounding.
If you want a different effect, hold on to the depressed keys, and gently release the pedal. That way, only those notes will continue to decay at their normal rate.
By being less than gentle, there will be the noise of all the dampers (except those held off by the keys held down) hitting the strings. Undesirable in most cases, possibly needed in a very modern piece!
There will be a slight extra decay time when just the pedal is held - as more strings will vibrate. And by releasing gently, either keys or pedal, you are in complete control as to when that decay finishes. Also, with a good pedal action, you can be even more gentle, and undampen really gradually, causing an almost echo effect.
While others are addressing the technique aspect, I wish to address the part about whether this is the right way to end a piece.
Unfortunately, the answer is "it depends." What you are doing is an effect, and the effect can be what you want, or not. Sometimes you do want an abrupt ending--especially if the last note is short. Sometimes you want to let it fade completely, without releasing at all.
But how can you tell? Listen to others. Watch videos or listen to recordings. See if they fade out or not. For specific pieces in classical literature, you'll probably want to do what most people do until you get your own style of play. But, for other stuff, you can listen and see what you prefer.
There are no hard and fast rules about how every piece of music ends--whether it fades out or not.