Ash-Shaykh Bin Baaz, rahimahullah, was asked the following question:

Question:

A questioner from Cairo, the Arab Republic of Egypt asks: If I am offering Salah [Prayer] and the bell rings and there is no other person in the house but me, what should I do?

Answer:

If it is a supererogatory [nafl/sunnah] Prayer, then the matter is flexible and there is no reason to interrupt the Prayer and find out who is at the door. But, if it is an obligatory Prayer, you should not rush unless there is something important that you fear you may miss. If it is possible to alert the person at the door that the person inside the house is busy praying, for instance by saying “Subhan Allah” (Glorified be Allah) for a man or clapping for a woman, then that is sufficient. The Prophet (peace be upon him) said:

“If something unusual happens in the Prayer, men should say, ‘Subhan Allah (Glorified be Allah)’ and women should clap.”

If it is possible to notify the person at the door that the man is praying by saying “Subhan Allah” or that the woman is praying by clapping, that should be done. If that will not serve any purpose [i.e. The worshiper is far from the door and will not be heard], then there is nothing wrong to interrupt the Prayer in the case it is necessary, especially in supererogatory Prayer. In the case of obligatory Prayer, if the worshiper feels something urgent by the knocker, they may interrupt the Prayer, open the door and then restart it from the beginning. Praise be to Allah.

[Reference]

Mentioned by

AbdulFattaah bin Uthman
Abu Fajr