Three Essentials step + One for more rescue:

  1. Remove all references to sid or unstable (or whatever you have you want to get rid of) in your /etc/apt/sources.list (and potentially /etc/apt/sources.list.d/*) by deleting, replacing, or commenting out. Ensure all those files has what you do want. For example:
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

deb http://cdn.debian.net/debian/ wheezy main contrib non-free
deb-src http://cdn.debian.net/debian/ wheezy main contrib non-free
  1. Pin the release you want in /etc/apt/preferences. If you are not sure what to put instead of stable you can have a look at where the majority of the packages you want to keep come from using api list --installed.
Package: *
Pin: release a=stable
Pin-Priority: 1001
  1. Finally we have to run the apt update and upgrade process for downgrading all packages.
apt-get update
apt-get upgrade
apt-get dist-upgrade
  1. If you have issues downgrading a package. Purge it, then reinstall
apt-get purge [your_failing_package]
apt-get install [your_failing_package]

This method isn’t bulletproof but might help rescue some systems.

Source