Creating a "new failsafe"

Hi all,

I wish to create a new failsafe for an university project, something simple, arbitrary but that may help to understand how to work on the code.

I was thinking something like force landing when the altitude is up to some limit i desire o something like that.

Any guide would be really helpful an apreciated.

thx!