A detective in Northern Ireland who survived a terrorist attack has retired from police.