Stellar collision
A stellar collision is the coming together of two stars caused by stellar dynamics within a star cluster, or by the orbital decay of a binary star due to stellar mass loss or gravitational radiation, or by other mechanisms not yet well understood.

Astronomers predict that events of this type occur in the globular clusters of our galaxy about once every 10,000 years. On 2 September 2008 scientists first observed a stellar merger in Scorpius (named V1309 Scorpii), though it was not known to be the result of a stellar merger at the time. A series of stellar collisions in a dense cluster over a short period of time can lead to an intermediate-mass black hole via "runaway stellar collisions".

Any stars in the universe can collide, whether they are 'alive', meaning fusion is still active in the star, or 'dead', with fusion no longer taking place. White dwarf stars, neutron stars, black holes, main sequence stars, giant stars, and supergiants are very different in type, mass, temperature, and radius, and so react differently.

A gravitational wave event that occurred on 25 August 2017, GW170817, was reported on 16 October 2017 to be associated with the merger of two neutron stars in a distant galaxy, the first such merger to be observed via gravitational radiation.

Types of stellar collisions and mergers

Type Ia supernova
White dwarfs are the remnants of low-mass stars and, if they form a binary system with another star, they can cause large stellar explosions known as type Ia supernovae. The normal route by which this happens involves a white dwarf drawing material off a main sequence or red giant star to form an accretion disc. Much more rarely, a type Ia supernova occurs when two white dwarfs orbit each other closely. Emission of gravitational waves causes the pair to spiral inward. When they finally merge, if their combined mass approaches or exceeds the Chandrasekhar limit, carbon fusion is ignited, raising the temperature. Since a white dwarf consists of degenerate matter, there is no safe equilibrium between thermal pressure and the weight of overlying layers of the star. Because of this, runaway fusion reactions rapidly heat up the interior of the combined star and spread, causing a supernova explosion. In a matter of seconds, all of the white dwarf's mass is thrown into space.

Neutron star mergers

Neutron star mergers occur in a fashion similar to the rare type Ia supernovae resulting from merging white dwarfs. When two neutron stars orbit each other closely, they spiral inward as time passes due to gravitational radiation. When they meet, their merger leads to the formation of either a heavier neutron star or a black hole, depending on whether the mass of the remnant exceeds the Tolman–Oppenheimer–Volkoff limit. This creates a magnetic field that is trillions of times stronger than that of Earth, in a matter of one or two milliseconds. Astronomers believe that this type of event is what creates short gamma-ray bursts and kilonovae.

Thorne–Żytkow objects

If a neutron star collides with red giant of sufficiently low mass and density, both can survive in the form of a peculiar hybrid known as Thorne–Żytkow object, with a neutron star surrounded by a red giant.

Binary star mergers 

About half of all the stars in the sky are part of binary systems, with two stars orbiting each other.  Some binary stars orbit each other so closely that they share the same atmosphere, giving the system a peanut shape.  While most contact binary stars are stable, a few have become unstable and have merged in the past for reasons not well understood (see relevant section below).

Formation of planets
When two low-mass stars in a binary system merge,
mass may be thrown off in the orbital plane of the merging stars,
creating an excretion disk from which new planets can form.

Discovery
While the concept of stellar collision has been around for several generations of astronomers, only the development of new technology has made it possible for it to be more objectively studied. For example, in 1764, a cluster of stars known as Messier 30 was discovered by astronomer Charles Messier. In the twentieth century, astronomers concluded that the cluster was approximately 13 billion years old. The Hubble Space Telescope resolved the individual stars of Messier 30. With this new technology, astronomers discovered that some stars, known as “blue stragglers”, appeared younger than other stars in the cluster. Astronomers then hypothesized that stars may have “collided”, or “merged”, giving them more fuel so they continued fusion while fellow stars around them started going out.

Stellar collisions and the Solar System
While stellar collisions may occur very frequently in certain parts of the galaxy, the likelihood of a collision involving the Sun is very small. A probability calculation predicts the rate of stellar collisions involving the Sun is 1 in 1028 years.
For comparison, the age of the universe is of the order 1010 years. The likelihood of close encounters with the Sun is also small. The rate is estimated by the formula:
N ~ 4.2 · D2 Myr−1
where N is the number of encounters per million years that come within a radius D of the Sun in parsecs. For comparison, the mean radius of the Earth's orbit, 1 AU, is .

Our star will likely not be directly affected by such an event, but the Earth may be easily affected by a nearby collision. Astronomers say that if a stellar collision happens within 100 light years of the Earth, the resulting gamma-ray burst could possibly destroy all life on Earth. This is still very unlikely though because there are no stellar clusters this close to the Solar System.

KIC 9832227 and binary star mergers
KIC 9832227 is an example of an eclipsing contact binary star system.  It is mainly composed of two stars orbiting each other so closely that they share the same atmosphere, giving the system a peanut shape.  
As the orbits of the two stars decay due to stellar mass loss and internal viscosity, the two stars will eventually merge,
resulting in a luminous red nova.

An analysis of the eclipses of KIC 9832227 initially suggested that its orbital period was indeed shortening,
and that the cores of the two stars would merge in 2022. 

However subsequent reanalysis found that one of the datasets used in the initial prediction contained a 12-hour timing error, leading to a spurious apparent shortening of the stars' orbital period.

The mechanism behind binary star mergers is not yet fully understood, and remains one of the main focuses of those researching KIC 9832227 and other contact binaries.