General theory of spontaneous emission near exceptional points