The best way to stop breastfeeding is to wean the baby and yourself from the process, rather than stopping suddenly. Stopping abruptly can cause your breasts to get painfully engorged or infected, and the baby may be fussy or not tolerate switching from the breast to bottle or solid food depending on their age. The best way to wean is to start either by shortening feed times, or substituting a feed per day with an alternative (bottle or food).
If your breasts are painful during this time, you may want to relieve them by hand expressing a small amount. Pumping instead of feeding will still feedback to your brain to produce milk, so if you must express or pump, do so very minimally so things can wind down. Ibuprofen, cold compresses, and tight bras can all help you during this process.