What stops Germanwings 9525 happening again — a suicidal pilot crashing the plane?
Any security precaution will be shared with the pilots. Therefore, a determined pilot will know those and be able to find ways to circumvent them beforehand.
What are some of the possible precautions?

Give both pilots their individual key? Easy - disable the lock before the other pilot leaves the cockpit, maybe by breaking off your own key when it is stuck into the lock.
Use a numeric keypad for unlocking the cockpit door which can only be reset on the ground? After the first terrorist attack where this system is abused, this will be disabled. And it is easy to figure out scenarios where the terrorists will learn the passcode from an unwitting pilot.
Similarly to military ground collision avoidance: Don't let the FCS allow too low flight levels outside of terminal areas? Disable the system by pulling the appropriate circuit breakers.
Let traffic control take over the plane by remote control when limits are exceeded? Easy again - just jam the radio signal. Again, it is easy to imagine scenarios where such a system is abused.

Also, what works for rail-based systems cannot be transferred to aviation. Stopping an airplane in mid-flight does not work as it does with trains.
The pilots have to be able to control the airplane exactly because in an unforeseen emergency they are the last resort which can bring it down in one piece. Taking away this ability does not enhance safety but would be the only basis of really stopping a suicidal pilot.