First of all, you're using the incorrect schematic symbol for a MOSFET. They are not the same as BJTs, and we just have to guess how you have it connected. MOSFETs do not have an emitter, collector, or base, so I am going to assume you have it connected such that the source is the emitter, the drain the collector, and the gate the base. Please use the correct symbol, especially if you're going to be asking others for help. They are not interchangeable with BJTs.
The MOSFET is not latching, it is simply doing what you've asked it to do. P-channel MOSFETs are switched by a negative voltage between the gate and source. Or, more simply, the gate voltage must be at a lower potential than the source to turn it on.
If you have 12V attached to the source of that MOSFET, then you must drive the gate with that same potential, 12V, to turn it off. This is equal to 0V from gate to source.
Likewise, assuming a turn-on voltage of 10V (the standard for MOSFETs), this is actually -10V gate-to-source, so reusing the 12V example, you would need to drive the gate with 2V, to fully turn on the MOSFET. This is -10V gate-to-source.
The reason your P-channel MOSFET 'latches' (not really latching, just behaving as expected) when you connect 12V, is because no matter what, you have -7V gate-to-source. When there is 5V on the gate, the MOSFET is on because you're keeping -7V on the gate (12V-5V=7V), which is more than enough to turn on any MOSFET. The threshold is usually -4.5V, and lower for logic level MOSFETs. If your ATMega's output goes high, you pull the gate of the MOSFET close to ground potential, driving the gate with -12V.
So your circuit is only capable of driving the MOSFET's gate in two modes: on, and really on.
It works at 5V because now, your gate drive voltage is able to match the source voltage, and you switch it between 0V gate-to-source, and -5V gate-to-source.
You will have to redesign that part of your circuit for it to work correctly. A common trick is to simply use a pull-up resistor between the gate and the source. This will keep the gate pulled up so it will default to the 'off' position. Now, you can simply use an npn transistor to pull the gate to ground to turn the MOSFET on. And who doesn't like making their circuit simpler?
A word of warning: what I described above will only work as long as the maximum gate to source voltage rating is observed. This is typically 20V, so 12V is no problem. But if you had, say, 30V on the source, then you will likely damage or destroy the MOSFET by pulling its gate to ground. This is would cause 30V across the gate and source.