Yes, it is correct grammatically but Russians will hardly use imperfective infinitive for this verb in this situation. It can be misunderstood.

Use imperative (either perfective or imperfective) for the command here: "Закрой дверь!" or "Закрывай!"

Or, if you want to be rude, use past perfective for this purpose: "Дверь закрыл!"