Almost a perfect ending in the dark (5)
I believe the answer is:
night
'the dark' is the definition.
(night is a kind of dark)
'almost a perfect ending' is the wordplay.
'almost' becomes 'nigh' ('nigh' can be a synonym of 'almost').
'ending' says to take the final letters.
The last letter of 'perfect' is 't'.
'nigh'+'t'='NIGHT'
'in' is the link.
(Other definitions for night that I've seen before include "''Tender is the ...'' (F Scott Fitzgerald)|" , "Period of darkness" , "For most, the time for sleep" , "Darkness; see you in the morning" , "late" .)